我在Android Studio中运行虚拟机.问题是它永远不会安装SD卡.在设置中,我尝试过工作室管理(100MB)以及自己创建一个:
$ ./mksdcard -l sdCard 100M sdcard.img
Run Code Online (Sandbox Code Playgroud)
该文件位于我的主文件夹中,具有R/W权限.
这是我的配置:
avd.ini.encoding=UTF-8
AvdId=DEVICEC_API_17
PlayStore.enabled=false
abi.type=x86
avd.ini.displayname=DEVICEC API 17
disk.dataPartition.size=800M
hw.accelerometer=no
hw.audioInput=yes
hw.battery=yes
hw.camera.back=emulated
hw.camera.front=emulated
hw.cpu.arch=x86
hw.cpu.ncore=4
hw.dPad=no
hw.device.manufacturer=User
hw.device.name=DEVICEC
hw.gps=no
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.initialOrientation=landscape
hw.keyboard=yes
hw.lcd.density=160
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=yes
hw.sensors.orientation=no
hw.sensors.proximity=no
hw.trackBall=no
image.sysdir.1=system-images/android-17/google_apis/x86/
runtime.network.latency=none
runtime.network.speed=full
sdcard.path=/home/user/sdcard.img
showDeviceFrame=no
skin.dynamic=yes
skin.name=800x600
skin.path=_no_skin
skin.path.backup=_no_skin
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=48
Run Code Online (Sandbox Code Playgroud)
如您所见,hw.sdCard设置为YES.
老实说,我不知道在Logcat中寻找什么.过滤MOUNT我看到了这个:
08-14 17:45:55.544 1495-1508/system_process I/SystemServer: Mount Service
08-14 17:45:55.544 1495-1508/system_process D/MountService: got storage path: /mnt/sdcard description: USB storage primary: true removable: false …Run Code Online (Sandbox Code Playgroud) 我试图了解 mongoDB 的每个元素是如何工作的,但我真的很困惑如何处理离线。
\n前往: https: //realm.io/
\n我读到了这个:
\n\n\nRealm\xe2\x80\x99s 移动数据库是 CoreData 和 SQLite 的开源、开发人员友好的替代方案。只需几分钟即可启动,几小时内即可移植您的应用程序,并节省数周的工作时间。
\n
然后这部分提到了离线部分:
\n\n\n专为离线使用而设计
\n
这是否意味着Realm可以在移动应用程序中用作完全离线的数据库?
\n如果我理解正确的话,这个数据库的工作方式与 Android Room 类似,我使用对象/文档存储数据。
\n因为当我转到“让我们开始”部分时,我被重定向到此处:
\nhttps://docs.mongodb.com/realm/get-started/introduction-mobile/
\n我在哪里读到这部分:
\n\n\n在开始之前,您需要一个 MongoDB Atlas 帐户。您可以在 Atlas 入门文档中了解有关创建 Atlas 帐户的更多信息
\n
所以我的第一个问题:为什么我需要 Atlas 帐户?我理解Atlas就是在云端有一个MongoDB数据库。如果我想使用离线数据库,为什么需要这个?
\n我想本教程想要展示所有工具的协同工作。所以也许可以跳过该步骤。但后来转到 React Native 教程,我看到了这部分:
\nhttps://docs.mongodb.com/realm/tutorial/react-native/#std-label-react-native-tutorial
\n\n\n连接到您的 MongoDB Realm 应用程序
\n
\n要让应用程序与您的后端一起工作,您首先需要实例化 Realm 应用程序。Realm 应用程序是 MongoDB Realm 后端的接口。导航到 getRealmApp.js 文件并完成 getRealmApp() …
我有一个使用 Maven 构建的 Spring-MVC 的 web 应用程序。当我生成 JAR 文件时,应用程序启动得很好。控制器正在执行,但是当我到达这一部分时:
@RequestMapping(value = "/test-block", method = RequestMethod.GET)
public ModelAndView block(Model model) {
return new ModelAndView("templates/test-block");
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
There was an unexpected error (type=Not Found, status=404).
/WEB-INF/templates/test-block.jsp
Run Code Online (Sandbox Code Playgroud)
请注意,在 IDE 中调试或运行可以正常工作。
我的文件夹:
src
|--main
|--java
|--com.xxx // sources
webapp
|--WEB-INF
|--templates
|--*.jsp // jsp files
resources
|--application.properties
Run Code Online (Sandbox Code Playgroud)
我的应用程序属性:
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
Run Code Online (Sandbox Code Playgroud)
我检查了生成的 JAR 文件,但在任何地方都看不到 WEB-INF。
编辑:
pom文件:
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud) 我正在创建一个小应用程序,它只是在数据库中保存一些计数器。如果它不存在,请插入一个。如果是,请增加更新。
该应用程序没有任何用户界面。它是一个保存和读取数据(少量表,少量记录)的插件。
在这种情况下,我可以使用allowMainThreadQueries()吗?每次我读到一些关于这个框架的教程时,总是说我不应该在生产中使用它。
我正在尝试将进程的日志保存到文件中。当我在 netbeans 中运行该类时,这工作正常,但在导出 JAR 文件后,该进程无法选择 logback.xml。
jar 文件与 logback.xml 位于同一路径中。我尝试使用我在这里找到的所有示例:
使用命令行文件:
java -Dlogback.configurationFile=logback.xml test.jar
Run Code Online (Sandbox Code Playgroud)
设置类路径:
java =cp "./" -jar test.jar
Run Code Online (Sandbox Code Playgroud)
这是配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} %M:%L- %msg%n</Pattern> -->
<Pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} %M:%L - %msg%n
</Pattern>
<!--<Pattern>%d{dd/MM/yyyy HH:mm:ss.SSS} [%thread] %-5level %C{0}:%L -
%msg%n</Pattern> -->
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>test.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!--<pattern>%-4relative [%thread] %-5level %logger{35} …Run Code Online (Sandbox Code Playgroud) 我已经制作了一个使用JPA和Spring的系统。例如,如果我需要处理帐户,则可以使用存储库:
@Repository
public interface AccountRepository extends JpaRepository<Account, Long>
Run Code Online (Sandbox Code Playgroud)
然后,我创建一个使用存储库的服务:
class AccountServiceImpl implements AccountService {
@Autowired
private AccountRepository repository;
@Transactional
public Account save(Account account){
return repository.save(account);
}
...
Run Code Online (Sandbox Code Playgroud)
现在,我创建了一个控制器,用于处理Accounts的POST方法:
@Controller
public class AccountController {
@Autowired
private final accountService service;
@RequestMapping(value = "/account", method = RequestMethod.POST)
public ModelAndView account(@Valid Account account, BindingResult bindingResult) {
...
service.save(account);
Run Code Online (Sandbox Code Playgroud)
客户,产品,联系人等相同
现在,假设我还有一个称为“注册”的类,该类包含足够的数据以创建一个带有客户,客户数据和产品(大量数据)的客户。一项针对注册的“确认”操作是专门用于执行此操作的操作:
@RequestMapping(value = "/confirm", method = RequestMethod.POST)
public ModelAndView confirmRegistration(@Valid Registration registration, BindingResult bindingResult) {
Run Code Online (Sandbox Code Playgroud)
现在我的问题是:为每个存储库调用save方法的正确方法是什么?
1)我应该在控制器中创建类,然后为每个创建的类调用save方法:
@RequestMapping(value = "/confirm", …Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的问题,当我尝试在连接的设备中使用应用程序时,我有一个闪烁的选项(出现一秒钟然后消失了,然后再次出现,依此类推):
当我尝试在任何连接的或虚拟设备中调试应用程序时,出现此错误:
01/23 18:49:36: Launching app
$ adb push D:\xxx\app\build\outputs\apk\debug\app-debug.apk /data/local/tmp/com.xxx.appname
Device emulator-5556disconnected, monitoring stopped.
Error while Installing APK
Run Code Online (Sandbox Code Playgroud)
我不是想依靠那个幽灵设备。我不知道模拟器5556是。试过虚拟电话和真实电话,并出现相同的错误。我唯一要做的就是使其工作,然后执行adb kill-server并选择要快速调试的设备。在emulator-5556设备开始再次出现之前。
问题是在那之后,如果我需要再次调试(因为我做了类似的更改),我需要再次杀死ADB,因为emulator-5556设备再次闪烁。真烦人。
如果当前 url 具有参数“action=edit”,我希望将某些控件标记为只读。
我尝试过以下方法:
网址:http://xxxx:8080/department?id=000001&action=edit
<input type="text" th:placeholder="#{department.id}" class="form-control" th:field="*{id}" th:readonly="${param.action == 'edit'}">
Run Code Online (Sandbox Code Playgroud)
由于某种原因,这总是错误的。我也尝试过展示价值:
<input type="text" class="form-control" th:value="${param.action}" th:readonly="${param.action=='edit'}">
Run Code Online (Sandbox Code Playgroud)
这显示输入中的值“编辑”,但只读仍然为假。然后我尝试了以下操作:“${param.action != 'edit'}”并且这是有效的。为什么?param.action 等于“edit”,但 IF 采用一些不同的值。
我理解错误信息.我知道我无法在静态上下文中访问非静态方法.但为什么我可以做到以下几点:
Predicate<String> t = String::isEmpty; // this works
Run Code Online (Sandbox Code Playgroud)
当isEmpty()是String类的非静态方法时?查看以下示例类.我理解不允许TestLamba :: isEmptyTest的逻辑; 但我不明白为什么String:isEmpty可以打破这个规则:
import java.util.function.Predicate;
public class TestLamba {
public static void main(String... args) {
Predicate<String> t = String::isEmpty; // this works
Predicate<String> t2 = TestLamba::isEmptyTest; // this doesn't
}
public boolean isEmptyTest() {
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
这是String.isEmpty的源代码.这是一种非常常见的方法,您可以看到它不是静态的:
public boolean isEmpty() {
return this.value.length == 0;
}
Run Code Online (Sandbox Code Playgroud) 我实际上正在将一些代码迁移到打字稿,所以我对所有这些类型的东西都是新手。当我将 redux-thunk 与常规 javascript 一起使用时,调度方法返回一个承诺,帮助我处理错误和其他内容。行动是这样的:
export const login = ({email, password}) => {
return async function (dispatch) {
try {
const result = await api.post(`/auth/login`, {username, password});
return dispatch({type: 'set_user_session', payload: result.data});
} catch (err) {
throw (err.response && err.response.data) || {code: err};
}
};
};
Run Code Online (Sandbox Code Playgroud)
然后我使用 useDispatch 钩子正常调用:
const dispatch = useDispatch();
...
dispatch(login({username: "admin", password: "adminpassword1"}))
.then(d => console.log("ok"))
.catch(err => console.log(err));
Run Code Online (Sandbox Code Playgroud)
现在我已将代码迁移到打字稿,操作现在如下所示:
export const login = ({username, password}: Credentials): ThunkAction<Promise<Action>, {}, {}, AnyAction> => {
// Invoke …Run Code Online (Sandbox Code Playgroud) 我有以下问题:
现在我有一个包含子网/掩码信息的表(例如 192.168.1.0 / 255.255.255.0 )..但我需要从此子网获取最大和最小 IP:
192.168.1.0 / 192.168.1.255
我找到了这个答案:
如何使用 postgres 查询最小或最大 inet/cidr
但似乎:
network_smaller(inet, inet)和network_larger(inet, inet)
不存在。即使谷歌搜索我也找不到这些功能的任何答案。
谢谢!
编辑:
版本信息:
x86_64-redhat-linux-gnu 上的 PostgreSQL 9.2.15,由 gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4) 编译,64 位
java ×5
android ×3
spring-mvc ×2
adb ×1
android-room ×1
java-8 ×1
jpa ×1
logback ×1
maven ×1
mongodb ×1
postgresql ×1
react-native ×1
realm ×1
redux ×1
redux-thunk ×1
spring ×1
spring-boot ×1
thymeleaf ×1
typescript ×1