使用Intellij IDEA重新加载远程Spring Boot应用程序时发生异常

蛋白石

我正在尝试使用spring devtools,docker和IntelliJ设置远程spring-boot环境一切都从本文开始不幸的是,它随机失败,但有例外。下面的配置:

Docker文件

FROM        java:8

EXPOSE      8888

WORKDIR     /app

ADD         build.gradle    /app/build.gradle
ADD         gradlew         /app/gradlew
ADD         gradle          /app/gradle

ADD         src             /app/src

RUN         ["chmod", "+x", "/app/gradlew"]

docker-compose.yml

backend:
  build: .
  env_file: environment
  ports:
    - "8888:8888"
  volumes:
    - ./.gradle-docker:/root/.gradle
  command: "/app/gradlew clean bootRun"
  links:
    - db

db:
  image:  postgres:9.5.3
  env_file: environment
  ports:
    - "5454:5432"

整个应用程序是从命令行启动的:docker-compose builddocker-compose up命令。

在IntelliJ中,我准备了以下Java应用程序配置: 配置

docker:8888spring应用程序使用的docker-machine和端口的IP在哪里运行配置后,将显示以下输出:

/\\ / ___'_ __ _ _(_)_ __  __ _          ___               _      \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` |        | _ \___ _ __  ___| |_ ___ \ \ \ \
\\/  ___)| |_)| | | | | || (_| []::::::[]   / -_) '  \/ _ \  _/ -_) ) ) ) )
 '  |____| .__|_| |_|_| |_\__, |        |_|_\___|_|_|_\___/\__\___|/ / / /
=========|_|==============|___/===================================/_/_/_/
:: Spring Boot Remote ::  (v1.3.5.RELEASE)

2016-07-06 12:48:51.997  INFO 17731 --- [           main] o.s.b.devtools.RemoteSpringApplication   : Starting RemoteSpringApplication v1.3.5.RELEASE on opal-mac.local with PID 17731 (/Users/opal/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-devtools/1.3.5.RELEASE/ab035bdc1e6297ff4c8676edd93ed307b11353c2/spring-boot-devtools-1.3.5.RELEASE.jar started by opal in /Users/opal/projects/backend)
2016-07-06 12:48:52.013  INFO 17731 --- [           main] o.s.b.devtools.RemoteSpringApplication   : No active profile set, falling back to default profiles: default
2016-07-06 12:48:52.106  INFO 17731 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@441772e: startup date [Wed Jul 06 12:48:52 CEST 2016]; root of context hierarchy
2016-07-06 12:48:54.016  WARN 17731 --- [           main] o.s.b.d.r.c.RemoteClientConfiguration    : The connection to http://docker:8888 is insecure. You should use a URL starting with 'https://'.
2016-07-06 12:48:54.419  WARN 17731 --- [           main] o.s.b.d.a.OptionalLiveReloadServer       : Unable to start LiveReload server
2016-07-06 12:48:54.499  INFO 17731 --- [           main] o.s.b.devtools.RemoteSpringApplication   : Started RemoteSpringApplication in 3.793 seconds (JVM running for 5.004)

不幸的是,对代码进行了一些更改之后,发生以下异常:

2016-07-06 12:49:29.141  INFO 17731 --- [   File Watcher] o.s.b.d.r.c.ClassPathChangeUploader      : Uploaded 1 class resource
2016-07-06 12:49:31.056  INFO 17731 --- [   File Watcher] o.s.b.d.r.c.ClassPathChangeUploader      : Uploaded 1 class resource
Exception in thread "File Watcher" java.lang.IllegalStateException: java.net.ConnectException: Connection refused
    at org.springframework.boot.devtools.remote.client.ClassPathChangeUploader.onApplicationEvent(ClassPathChangeUploader.java:107)
    at org.springframework.boot.devtools.remote.client.ClassPathChangeUploader.onApplicationEvent(ClassPathChangeUploader.java:56)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)
    at org.springframework.boot.devtools.classpath.ClassPathFileChangeListener.publishEvent(ClassPathFileChangeListener.java:68)
    at org.springframework.boot.devtools.classpath.ClassPathFileChangeListener.onChange(ClassPathFileChangeListener.java:64)
    at org.springframework.boot.devtools.filewatch.FileSystemWatcher.fireListeners(FileSystemWatcher.java:230)
    at org.springframework.boot.devtools.filewatch.FileSystemWatcher.updateSnapshots(FileSystemWatcher.java:223)
    at org.springframework.boot.devtools.filewatch.FileSystemWatcher.scan(FileSystemWatcher.java:183)
    at org.springframework.boot.devtools.filewatch.FileSystemWatcher.access$100(FileSystemWatcher.java:41)
    at org.springframework.boot.devtools.filewatch.FileSystemWatcher$1.run(FileSystemWatcher.java:150)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1169)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:933)
    at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:80)
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
    at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93)
    at org.springframework.boot.devtools.remote.client.HttpHeaderInterceptor.intercept(HttpHeaderInterceptor.java:57)
    at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:85)
    at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:69)
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
    at org.springframework.boot.devtools.remote.client.ClassPathChangeUploader.onApplicationEvent(ClassPathChangeUploader.java:102)
    ... 12 more

在docker和IntelliJ中:

2016-07-06 12:49:29.141  INFO 17731 --- [   File Watcher] o.s.b.d.r.c.ClassPathChangeUploader      : Uploaded 1 class resource

日志中,我看到上下文已重新加载。可能是什么问题?

安迪·威尔金森(Andy Wilkinson)

Spring boot的DevTools中存在一个错误,这意味着如果在仍由上一个更改触发的重新启动过程中对应用程序进行更改,则上载更改的尝试将失败。我认为我们可能需要更新DevTools才能重试上传尝试。

同时,唯一的“解决方案”是,RemoteSpringApplication一旦您看到由于导致的故障,便停止并重新启动您的计算机java.net.ConnectException: Connection refused

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Spring Boot执行时,应用程序启动方法中的JavaFX异常

在Docker中运行Spring Boot应用程序时发生异常

尝试调试Spring Boot Rest应用程序时发生未授权的错误

尝试使用dynamodb和graphql运行我的Spring Boot应用程序时,我不断收到此@bean错误

启动Spring-boot应用程序时出现异常

使用IntelliJ运行Go应用程序时加载配置文件

部署Spring Boot Okta应用程序时发生SunCertPathBuilderException

使用Maven运行Spring Boot应用程序时出错:参数绑定的名称不能为null

使用Spring-Security时在Docker中自动重新加载Spring Boot应用程序

使用tomcat启动Spring Boot应用程序时出现java.lang.VerifyError

启动Spring Web MVC应用程序时发生异常

Spring Boot:退出应用程序时发生异常

运行Spring Session + Spring Boot应用程序时发生运行时错误

调试独立的Spring Boot应用程序(Intellij IDEA)

通过Idea打开Gradle应用程序时引发异常

使用IntelliJ部署支持嵌入式tomcat的spring-boot应用程序

未加载应用程序,但在Django中使用多处理时发生异常

Spring Boot应用程序的Intellij IDEA中缺少映射

在IntelliJ中运行Spring Boot Gradle应用程序时始终获取404

从Spring Boot应用程序使用DB2 Wirelistener(NoSQL)的异常

执行简单的Spring Boot应用程序时出现IllegalAccessError异常

使用ionic构建phonegap应用程序时发生错误

Spring Boot应用程序IntelliJ

NSUserDefaults在使用应用程序时保存并重新加载,但在重新启动应用程序时重置

在Intellij IDEA 14.1中运行Spring Batch应用程序时出错

使用Spring Boot保护Web应用程序-导致thymeleaf异常

为什么在使用Spring Boot运行应用程序时会遇到SpringIntegration异常

使用mongodb的spring数据进行Spring boot:加载应用程序时出错

在带有Spring 4.3和JRebel的tomcat8中部署Java应用程序时发生异常