使用Intellij IDEA重新加载远程弹簧启动应用程序的异常 [英] Exception on reloading remote spring boot application with Intellij IDEA
问题描述
我正在尝试使用spring
其中 docker:8888
是spring应用程序使用的docker-machine和port的IP。运行配置后,输出如下:
/ \\ / ___'_ __ _ _(_)_ __ __ _ ___ _ \ \ \ \
(()\ ___ |'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ___ \ \ \ \
\\ / ___)| | _)| | | | | || (_ | [] :::::: [] / -_)'\ / _ \ _ / -_)))))
'| ____ | .__ | _ | | _ | _ | | _\__,| | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ======== | ___ / =================================== / _ / _ / _ /
:: Spring Boot Remote ::(v1.3.5.RELEASE)
2016-07-06 12:48:51.997 INFO 17731 --- [main] osbdevtools。 RemoteSpringApplication:启动RemoteSpringApplication v1.3.5.RELEASE在opal-mac.local与PID 17731(/Users/opal/.gradle/cache/modules-2/files-2.1/org.springframework.boot/spring-boot-devtools/1.3 .5.RELEASE / ab035bdc1e6297ff4c8676edd93ed307b11353c2 / spring-boot-devtools-1.3.5.RELEASE.jar由/ Users / opal / projects / backend中的opal开始)
2016-07-06 12:48:52.013 INFO 17731 - - [main] osbdevtools.RemoteSpringApplication:没有活动的配置文件设置,回退到默认配置文件:default
2016-07-06 12:48:52.106 INFO 17731 --- [main] scaAnnotationConfigApplicationContext:Refreshing org。 springframework.context.annotation.AnnotationConfigApplicationContext@441772e:启动日期[Wed Jul 06 12:48:52 CEST 2016];上下文层次结构
2016-07-06 12:48:54.016 WARN 17731 --- [main] o.s.b.d.r.c.RemoteClientConfiguration:与http:// docker:8888的连接是不安全的。您应该使用以https://开头的网址。
2016-07-06 12:48:54.419 WARN 17731 --- [main] osbdaOptionalLiveReloadServer:无法启动LiveReload服务器
2016-07-06 12:48:54.499 INFO 17731 --- [主要] osbdevtools.RemoteSpringApplication:在3.793秒内启动RemoteSpringApplication(JVM运行5.004)
更改代码,发生以下异常:
2016-07-06 12:49:29.141 INFO 17731 - - [File Watcher] osbdrcClassPathChangeUploader:已上传1类资源
2016-07-06 12:49:31.056 INFO 17731 --- [文件监视器] osbdrcClassPathChangeUploader:已上传1类资源
线程中的异常文件监视器java.lang.IllegalStateException:java.net.ConnectException:连接拒绝
在org.springframework.boot.devtools.remote.client.ClassPathChangeUploader.onApplicationEvent(ClassPathChangeUploader.java:107)
在org .spri ngframework.boot.devtools.remote.client.ClassPathChangeUploader.onApplicationEvent(ClassPathChangeUploader.java:56)
在org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
在org。 springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
在org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)
在org.springframework.context。 support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)
在org.springframework.boot.devtools.classpath.ClassPathFileChangeListener.publishEvent(ClassPathFileChangeListener.java:68)
在org.springframework.boot.devtools。 classpath.ClassPathFileChangeListener.onChange(ClassPathFileChangeListener.java:64)
在org.springframework.boot.devtools.filewatch.FileSystemWatcher.fireListeners(File SystemWatcher.java:230)
在org.springframework.boot.devtools.filewatch.FileSystemWatcher.updateSnapshots(FileSystemWatcher.java:223)
在org.springframework.boot.devtools.filewatch.FileSystemWatcher.scan( FileSystemWatcher.java:183)
在org.springframework.boot.devtools.filewatch.FileSystemWatcher.access $ 100(FileSystemWatcher.java:41)
在org.springframework.boot.devtools.filewatch.FileSystemWatcher $ 1。 run(FileSystemWatcher.java:150)
导致:java.net.ConnectException:连接拒绝
在java.net.PlainSocketImpl.socketConnect(本机方法)
在java.net.AbstractPlainSocketImpl。 doConnect(AbstractPlainSocketImpl.java:350)
在java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
在java.net.Socket.connect(Socket.java:589)
在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)
在org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:80)
at o rg.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
在org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
在org.springframework。 http.client.InterceptingClientHttpRequest $ InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93)
在org.springframework.boot.devtools.remote.client.HttpHeaderInterceptor.intercept(HttpHeaderInterceptor.java:57)
在org。 SpringFramework.http.client.InterceptingClientHttpRequest $ InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:85)
在org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:69)
在org.springframework。 http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
在org.springframework.http.client.AbstractClientHttpRequest。执行(AbstractClientHttpRequest.java:53)
在org.springframework.boot.devtools.remote.client.ClassPathChangeUploader.onApplicationEvent(ClassPathChangeUploader.java:102)
... 12更多
在码头和IntelliJ中:
2016-07-06 12:49:29.141 INFO 17731 --- [File Watcher] osbdrcClassPathChangeUploader:已上传1个类资源
日志我看到上下文被重新加载。可能是什么问题?
有一个错误在Spring boot的DevTools中,这意味着如果您对应用程序进行更改,而上次更改触发的重新启动仍在进行中,则尝试上传更改将会失败。我想我们可能需要更新DevTools以重试上传尝试。
同时,唯一的解决方案是停止并重新启动您的 RemoteSpringApplication
每当您看到由于 java.net.ConnectException:Connection拒绝
。
I'm trying to setup remote spring-boot environment using spring devtools, docker and IntelliJ. All started with this article. Unfortunately it randomly fails with an exception. Below the configuration:
Dockerfile
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"
The whole application is started from command line with: docker-compose build
and docker-compose up
commands.
In IntelliJ I've prepared the following java application configuration:
where docker:8888
is the IP of the docker-machine and port that is used by spring application. After the configuration is run is the following output:
/\\ / ___'_ __ _ _(_)_ __ __ _ ___ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | | _ \___ _ __ ___| |_ ___ \ \ \ \
\\/ ___)| |_)| | | | | || (_| []::::::[] / -_) ' \/ _ \ _/ -_) ) ) ) )
' |____| .__|_| |_|_| |_\__, | |_|_\___|_|_|_\___/\__\___|/ / / /
=========|_|==============|___/===================================/_/_/_/
:: 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)
Unfortunately after some change is made to the code, the following exception occurs:
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
In docker and IntelliJ:
2016-07-06 12:49:29.141 INFO 17731 --- [ File Watcher] o.s.b.d.r.c.ClassPathChangeUploader : Uploaded 1 class resource
logs I see that the context is reloaded. What may be the problem?
There's a bug in Spring boot's DevTools which means that if you make a change to your application while the restart that was triggered by the previous change is still in progress, the attempt to upload the changes will fail. I think we probably need to update DevTools to retry the upload attempt.
In the meantime, the only "solution" is to stop and restart your RemoteSpringApplication
whenever you see the failure due to java.net.ConnectException: Connection refused
.
这篇关于使用Intellij IDEA重新加载远程弹簧启动应用程序的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!