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

2023-12-25

我正在尝试使用 spring 设置远程 spring-boot 环境devtools http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html、docker 和 IntelliJ。一切由此开始article https://medium.com/@lhartikk/development-environment-in-spring-boot-with-docker-734ad6c50b34#.z27jyzita。不幸的是,它随机失败,但有例外。配置如下:

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"

整个应用程序从命令行启动:docker-compose build and docker-compose up命令。

In IntelliJ I've prepared the following java application configuration: configuration

where docker:8888是 docker-machine 的 IP 和 spring 应用程序使用的端口。配置运行后输出如下:

/\\ / ___'_ __ _ _(_)_ __  __ _          ___               _      \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` |        | _ \___ _ __  ___| |_ ___ \ \ \ \
\\/  ___)| |_)| | | | | || (_| []::::::[]   / -_) '  \/ _ \  _/ -_) ) ) ) )
 '  |____| .__|_| |_|_| |_\__, |        |_|_\___|_|_|_\___/\__\___|/ / / /
=========|_|==============|___/===================================/_/_/_/
:: 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

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


有一个bug https://github.com/spring-projects/spring-boot/issues/6339在 Spring boot 的 DevTools 中,这意味着如果您对应用程序进行更改,而由先前更改触发的重新启动仍在进行中,则尝试上传更改将失败。我认为我们可能需要更新 DevTools 才能重试上传尝试。

与此同时,唯一的“解决方案”是停止并重新启动您的RemoteSpringApplication每当你看到由于以下原因而失败时java.net.ConnectException: Connection refused.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用Intellij IDEA重新加载远程Spring Boot应用程序时出现异常 的相关文章

随机推荐

  • 如何在nhibernate中使用PK删除对象?

    如何删除对象而不先从数据库中获取它 在另一个 ORM 中 我可以这样做 session Delete
  • mojolicious 引用的存储变量并不总是定义的

    我仍在学习 mojolicious 和 MVC 框架 所以这可能是一个问题 我认为这个问题是错误的 所以如果我愿意 请建议一种更好的方法来执行以下操作 我有一条路线 route param 其中 param 有时被定义 有时则没有 我尝试在
  • 为什么“--force-recreate”不重建我的 docker mysql 映像?

    我创建了一个 docker MySql 5 7 映像 然后想更改几个名称 我的 docker compose yml 文件最终像这样 version 3 3 services db image mysql 5 7 restart alway
  • 未找到 osx sys/io.h

    我想在 os x 下使用 cc 编译为 linux 开发的 c 程序 它包括标头 sys io h 编译的时候报错说找不到这个文件 os x下不是有sys io h头文件吗 任何帮助将非常感激 Thanks Include
  • 更改flutter应用程序图标的背景颜色

    我想将背景图标更改为 fe6017 I use flutter launcher icons set adaptive icon background fe6017 但这不起作用 我也尝试调整图像大小 但它总是收缩并放置white我的图像周
  • 如何使用JW Player播放rtmp流?

    我想知道如何使用 JW Player 流式传输 RTMP 我刚刚开始 嵌入没有帮助 因此如果有人可以分享适合他的代码 将会有所帮助 我们这里有一个指南 http www longtailvideo com support jw player
  • jqgrid 获取所有网格列名称

    有没有办法获取网格的所有列名称 您可以使用以下方式获取列名称 var columnNames list 0 p colNames or var columnNames list jqGrid getGridParam colNames 唯一
  • 给定日期范围内的每日活跃用户数

    我需要根据开始日期和结束日期查找每日活跃用户总数 报名表 id registration no start date end date 1 1000 2014 12 01 2014 12 03 2 1001 2014 12 01 2014
  • PHP 中的“贪婪标记解析”是什么?

    PHP 中的 贪婪标记解析 是什么 我在 Codeigniter 指南中找到了这一点 除非需要解析变量 否则始终使用单引号字符串 并且在确实需要解析变量的情况下 请使用大括号来防止贪婪标记解析 我的字符串 foo 带有良好解释的答案会有所帮
  • React 和 babel 中的可选链接运算符

    在我的项目中我配置 babel presets react es2015 stage 1 transform optional chaining plugins transform runtime 这是我的devDependencies i
  • 如何一次运行多种语言的 tesseract?

    我必须分析包含英语和日语文本的图像 当我默认运行 tesseract 时 l eng 一些日语字符丢失了 否则 如果我用日语运行 tesseract l jpn 一些英文字符丢失 例如电子邮件 如何运行一个同时识别英语和日语字符的进程 从
  • dlopen 与链接开销

    假设我有一个库 foo so 当构建我的二进制文件 需要这个库 时 我可以 1 链接 foo so 或者 2 在程序源代码中 dlopen 这个库 然后调用这个库提供的函数 当我从库中调用函数时 1 和 2 之间有性能差异吗 请注意 我知道
  • 为什么 VB 中的 lambda 表达式与 C# 中不同?

    我刚刚在 NHibernate 中遇到了一个错误 该错误恰好已经被提出 https nhibernate jira com browse NH 2763 https nhibernate jira com browse NH 2763 我不
  • 将 duff 的设备从 C 移植到 JavaScript

    我有这种 Duff 的 C 语言设备 它工作正常 将文本格式设置为金钱 include
  • 带有 IIS 的 Kestrel - 运行时缺少 libuv.dll

    我们正在设置一个现有的 Web API 服务器 以便与现有的 API 一起为站点提供服务 我一直在松散地关注本文 http miniml ist dotnet how to serve a static site plus a web ap
  • 解析 WSDL 的简单方法

    我正在尝试解析 WSDL 以获取操作 端点和示例有效负载 用户输入的 WSDL 我找不到执行此操作的教程 我只能找到生成我不需要的源代码的那些 我尝试过使用 XBeans 但显然我需要 Saxon 有没有一种简单的轻量级方法可以在没有 Sa
  • 我如何处理异常?

    Angular 有一个很棒的 异常处理程序 https docs angularjs org api ng service 24exceptionHandler React js 有类似的东西吗 我想将我的错误记录到外部 API 例子 ht
  • SoundCloud track.stream_url 对某些曲目不起作用

    我注意到在 soundcloud 上的某些曲目上 stream url 指向 404 页面未找到 该曲目已设置为可流式传输 但流式传输 URL 仍然不起作用 这是一个例子 http api soundcloud com tracks 129
  • 向 R 绘图添加类似 Excel 功能的方法? [关闭]

    很难说出这里问的是什么 这个问题是含糊的 模糊的 不完整的 过于宽泛的或修辞性的 无法以目前的形式得到合理的回答 如需帮助澄清此问题以便重新打开 访问帮助中心 help reopen questions 我一直在研究 R 图形参数 试图让我
  • 使用Intellij IDEA重新加载远程Spring Boot应用程序时出现异常

    我正在尝试使用 spring 设置远程 spring boot 环境devtools http docs spring io spring boot docs current reference html using boot devtoo