问题标签 [spring-boot-devtools]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
911 浏览

java - Spring Boot 与 devtools 调用 SOAP API

我正在部署一个项目 Spring Boot,使用 devtools(spring-boot-devtools) 并调用 Soap 服务。我将 Soap 类生成到 /src/main/resources/templates/generated 并将这个文件夹添加为源代码。因为当调用这个 Soap 服务时,它有一个问题:

java.lang.IllegalArgumentException: ...ClassV11PortType 从方法引用在类加载器中不可见

因此,我将 spring-devtools.properties 文件添加到 /src/main/resources/META-INF/spring-devtools.properties 并将这一行添加到 spring-devtools.properties 文件中:

restart.exclude.mygeneratedclasses =/ [packageOfGeneratedClass] .class

那么现在,我可以成功调用 SOAP 服务了。但是现在,当我修改一些代码时,我的项目无法自动重新加载。我试图在任何地方编辑一些代码并保存但不是运气,我的项目没有重新加载。

0 投票
0 回答
264 浏览

java - Spring boot - 以交互模式运行集成测试

在开发 Web 应用程序时,SpringBoot 开发工具模块可以方便地加快编译和运行循环。但是,我找不到任何类似的集成测试功能。

更具体地说,假设我有一个集成测试(用@RunWith(SpringRunner.class)and注释@SpringBootTest),它在随机端口上启动一个 Web 服务器并测试一些 REST 端点。我想要一个交互式测试运行器,它不会在测试用例失败时终止进程。相反,它将等待代码中的更改,如果检测到更改,它将重新加载并重新运行测试(就像开发工具中的热交换一样)

我对这个功能的搜索没有成功,所以我想知道实现这个功能的最快方法是什么。考虑到 Springs 的受欢迎程度,为什么没有广为人知的方式来做到这一点?

编辑

在源代码中挖掘了一下,我发现了以下一段代码。

由此,我了解到作者明确禁用了对测试的支持。谁能解释一下?

0 投票
0 回答
394 浏览

java - 如何用 axon 解决 spring-boot-devtools 的问题?

我必须在 spring-boot 应用程序中使用 spring-boot-devtools & axon。我已将它们都包含在 pom.xml 中。它不工作。应用程序无法启动。

我尝试在不使用 spring-boot-devtools 的情况下运行应用程序,然后它可以按预期完美运行,但不能使用 spring-boot-devtools。我已经阅读了https://docs.axoniq.io/reference-guide/setting-up/spring-boot上的 axon 文档,建议不要将 devtools 与 axon 一起使用。我还提到了问题https://github.com/AxonFramework/AxonFramework/issues/976,其中指出,删除 devtools 依赖项就可以了。我不想删除 devtools,因为它在开发模式下很有用。Pom.xml 内容:

我希望应用程序启动但出现错误:

说明:无法注册在类路径资源 [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class] 中定义的 bean 'commandBus'。已在类路径资源 [org/axonframework/springboot/autoconfig/AxonServerAutoConfiguration.class] 中定义了具有该名称的 bean,并且禁用了覆盖。

行动:考虑重命名 bean 之一或通过设置 spring.main.allow-bean-definition-overriding=true 来启用覆盖

我试过 spring.main.allow-bean-definition-overriding=true 但不工作。

0 投票
1 回答
21 浏览

spring - 春季开发工具故障排除

我在使用 spring devtools 时遇到问题。它没有对类文件进行任何更改。我已经尽可能多地确认了配置和实际更改的文件。

在获取其他信息方面我有哪些选择(例如增加日志记录、获取监控的路径、记录最后看到的时间戳、它是否完全处于活动状态等)?

编辑:还有一些注意事项,该项目是 gradle + kotlin,仅限命令行。我gradle bootRun在一个终端和gradle compileKotlin另一个终端上运行。我确认编译发生并且build/classes正在更新中的类(查看时间戳)。

0 投票
0 回答
61 浏览

intellij-idea - Spring-Boot-Devtools 与 Intellij IDEA 的兼容性问题,Spring-Boot-Devtools live-reload 上的编译错误

我在使用Spring-Boot-Devtools. 每次我更新我的控制器类时,spring 都找不到使用构造函数注入注入的依赖项。

假设我有这门课

对任何控制器方法或MyService's 方法的更改都会导致一些错误,例如:constructor in com.example.MyController required a bean of type 'com.example.MyService' that could not be found

而如果我在 Eclipse 上运行相同的代码,实时重新加载工作正常。

IntelliJ IDEA 2019.1.2 (Ultimate Edition)
JRE: 1.8.0_202-release-1483-b49 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains sro
macOS 10.13.6

毕业典礼 在此处输入图像描述

0 投票
1 回答
1413 浏览

spring-boot - Spring Boot devtools - 有时重新加载的bean在重新启动时不会被拾取

我在使用 spring-devtools 重启功能时遇到了一些问题。似乎有时由于未知原因更改并且重新加载的 bean 没有被拾取。

应用类:

命令行运行器:

更改并重新加载的服务:

pom.xml:

通常第一次重新加载工作正常:

但是第二次或第三次崩溃如下,其中包含有关丢失 bean 的信息:

有谁知道发生了什么?任何帮助表示赞赏。

0 投票
4 回答
8511 浏览

spring - Live reload for thymeleaf template

When I change a thymeleaf .html file residing inside /templates , I expect the browser to automatically reload the page. I have the live reload plugin installed and its able to do a handshake with the spring boot server. However , upon chaning a thymeleaf template file , I have to manually reload the browser. Any suggestions what I might be missing. Obviously I have spring-boot-devtools enabled and have also manually updated the property devtools.livereload.enabled = true. And spring devtools is correctly relecting changes to any template or controller in build target , and with a manual reload of browser , I see the changes.

As per spring docs.

Certain resources do not necessarily need to trigger a restart when they are changed. For example, Thymeleaf templates can be edited in-place. By default, changing resources in /META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates does not trigger a restart but does trigger a live reload.

I have my local running over a broken https. ( Some certificate issue , which causes a not secure message in chrome address bar. Could this be the reason live reload is not working.

0 投票
2 回答
480 浏览

java - 如何从 Spring-Devtools 重启周期中排除使用 WSDL 生成的类?

当我在启用 Spring-Devtools 并从 WSDL 模式生成的类的情况下启动 Spring Boot 应用程序时,我得到:

Caused by: java.lang.IllegalArgumentException: org.wsdl.WsdlServiceWs referenced from a method is not visible from class loader

我有一个基于 Spring Boot 的项目,其中包含使用org.apache.cxf:cxf-codegen-plugin插件从 WSDL 文件生成的一些类。生成的类存储在target/generated/wsdl/**目录中。生成类的包名与工程包名不同。

我在文档之后尝试了几个排除项:

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-devtools-restart-exclude

但我所有的尝试都失败了。

我想启用 Spring-Devtools,将 org.wsdl.** 生成的类排除在重启周期之外。

0 投票
0 回答
1078 浏览

spring-boot - 使用 devtools 时 Spring Boot 应用程序空闲 CPU 使用率过高

在我的 Windows 10 笔记本电脑上从 Eclipse 启动 Spring Boot 2.2 应用程序后,我注意到大约 10% 的永久 CPU 使用率和时钟频率。即使应用程序处于空闲状态,也几乎低于 2 GHz。

当我停止应用程序时,cpu 使用率下降到 1-2%,时钟低于 1 GHz。

应用程序每分钟执行一次 sql 查询,但除此之外在空闲时不进行处理。它基本上坐在那里等待请求。

我怎样才能弄清楚是什么导致这种使用似乎阻止了 cpu(带有 8GB ram 的 i7-5600U)节流?

我使用 Java 1.8.0_221。

编辑 1 我尝试从 cmd.exe 运行编译后的 jar,然后空闲 cpu 使用率很低。

编辑 2 我尝试在 pom.xml 中禁用 spring-boot-devtools,并且空闲 cpu 使用率也很低。

编辑 3 这可能是问题所在:https ://github.com/spring-projects/spring-boot/issues/9882感觉就像为排除的文件夹和文件设置了 FileWatcher,在我的情况下是 bower_components 有数千的文件。

0 投票
1 回答
747 浏览

spring - 如何在没有 @EnableAutconfiguration 或 @SpringBootApplication 的情况下使 spring-boot-devtools 工作?

我正在使用 spring-boot v1.3.5.RELEASE 开发一个应用程序,它不使用@SpringBootApplication也不@EnableAutconfiguration(客户要求)。

我想spring-boot-devtools在我的 IDE 中启用“重启”功能。我把它作为依赖,打mvn spring-boot:run。重启器工作:

但是在 IDE 代码修改和 rebluid 后它不会重新加载(在 eclipse 上按 Ctrl+B)。

问题似乎是 devtools 依赖于@EnableAutconfiguration(加载了 的工厂META-INF/spring.factories)进行配置(我不能使用这个注释)。基本上,我需要自己做(见下面的 devtoolsspring.factories文件的内容):

我该怎么做(我对spring-boot lingua不是特别流利)?