通过以下方式启动java进程有什么区别:
java -jar application.war
Run Code Online (Sandbox Code Playgroud)
和
java -classpath application.war org.example.Main
Run Code Online (Sandbox Code Playgroud)
问题是我正在使用-jar参数启动Spring Boot Application,进程正常启动,但在eclipse应用程序启动时出现异常:
Caused by: java.lang.ClassNotFoundException: com.sun.istack.localization.Localizable
Run Code Online (Sandbox Code Playgroud) 我有2个服务,其中一个是生产者(将对象保存到领域),以及其他从领域读取此对象并在计划任务中将它们发送到REST服务.
我的例外:
java.lang.IllegalStateException: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created.
Run Code Online (Sandbox Code Playgroud)
服务1:
this.scheduler.schedule("*/2 * * * *", new Runnable() {
public void run() {
List<Location> locations = dataStore.getAll(Location.class);
for(Location l : locations) {
try {
serverEndpoint.putLocation(l);
l.removeFromRealm();
} catch (SendingException e) {
Log.i(this.getClass().getName(), "Sending task is active!");
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
服务2:
private LocationListener locationListener = new android.location.LocationListener() {
@Override
public void onLocationChanged(Location location) {
TLocation transferLocation = new TLocation();
transferLocation.setLat( …Run Code Online (Sandbox Code Playgroud) 从yeasterday开始,我正试图通过ajax将文件上传到我的Spring应用程序.这是我的控制器:
@RequestMapping(value="/upload", method=RequestMethod.POST)
@ResponseBody
public String uploadFile(
@RequestParam("file") MultipartFile file, Principal principal )
{
if( principal != null ) {
}
return "";
}
Run Code Online (Sandbox Code Playgroud)
在HTML代码中形成:
<form id="uploadImageForm"
name="uploadImageForm"
enctype="multipart/form-data">
<div class='dialog' style='width:200px;'>
<div class='green_button' id='files' name='files'>
<div class='green_button_text' id="add_image">
wybierz zdj?cie
</div>
<input type="file" name="file" id="fileInputHidden" style="display:none"/>
</div>
<script>
$("#add_image").click(function(){
$("input[id='fileInputHidden']").click();
});
</script>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
通过ajax发送文件的脚本:
document.getElementById('fileInputHidden').addEventListener('change', this.onFileChange, false);
},
this.onFileChange = function( evt ) {
var file = evt.target.files[0];
if( !file != null ) {
if (!!file.type.match(/image.*/)) …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建从套接字描述符中读取的线程.需要使用非阻塞循环来检查当前时间并在会话结束后关闭套接字,但FD_ISSET即使在套接字上可以读取数据也会返回0.
fd_set fds;
FD_ZERO(&fds);
FD_SET(session_ref->fd, &fds);
while(1)
{
while(1)
{
FD_CLR(session_ref->fd, &fds);
FD_SET(session_ref->fd, &fds);
n = select( session_ref->fd, &fds, NULL, NULL, &timeout ); // n = 0
if( FD_ISSET( session_ref->fd, &fds ) )
break;
else
{
// some operations
}
sleep(1);
}
n = read( session_ref->fd, buffer, 2048 );
printf("Read: %i\n", n);
}
Run Code Online (Sandbox Code Playgroud)
我犯了什么错误?