gpt4 book ai didi

spring-boot - Spring Boot Devtools 重启不会自动与 Spring Boot 1.5.4 一起使用

转载 作者:行者123 更新时间:2023-12-01 01:46:25 28 4
gpt4 key购买 nike

我在网上看了很多关于 spring-boot-devtools 的文章和问题,但仍然无法弄清楚为什么它对我不起作用。每次运行我的应用程序时,我都会得到以下信息:

17:54:28.057 [main] DEBUG 
org.springframework.boot.devtools.settings.DevToolsSettings
- Included patterns for restart : []

17:54:28.066 [main] DEBUG
org.springframework.boot.devtools.settings.DevToolsSettings
- Excluded patterns for restart : [/spring-boot-starter/target/classes/,
/spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/,
/spring-boot/target/classes/, /spring-boot-actuator/target/classes/,
/spring-boot-devtools/target/classes/]

17:54:28.069 [main] DEBUG
org.springframework.boot.devtools.restart.ChangeableUrls - Matching
URLs for reloading : [file:/some/where/build/classes/main/,
file:/some/where/build/resources/main/]

每当我更改我的 Controller 文件之一时,什么也没有发生。所以我came across an article那提到我应该尝试将 spring.devtools.restart.additional-paths=/src 添加到我的应用程序属性文件中。使用 /src 将不起作用,因为它会认为它是绝对路径,所以我将其更改为 src。这样做之后,将新端点添加到我的 Controller 文件并保存它会触发 Spring Boot 重启。但是,我得到了一个 404 端点,这只有在我手动重新启动服务器时才有效。

如何让 Spring Boot 重启并让我看到我对 Controller 所做的实际更改?

我在 build.gradle 中使用 Spring Boot 1.5.4 和以下内容:

dependencies {
// ...
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-devtools')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

我的应用具有以下结构:

build/
src/
main/
java/
com/
example/
something/
controllers/
MyController.java
SomethingApplication.java
resources/
application.yml
test/
...

我的application.yml包括

spring:
devtools:
restart:
enabled: true
additional-paths: src

最佳答案

请检查 application.yml 或 logback-spring.xml 文件中提供的路径。

例如:你的 logback 中的 LOG_HOME 配置为 E:/logs 但你的笔记本/台式机中没有 E:/驱动器。

因此找不到匹配的 url,处理停止。

我也遇到了同样的问题,我更正了 logback-spring.xml 文件中的路径。

谢谢!

问候,阿努拉格

关于spring-boot - Spring Boot Devtools 重启不会自动与 Spring Boot 1.5.4 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45179385/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com