【发布时间】:2017-07-19 01:05:49
【问题描述】:
我在网上查看了很多关于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/]
每当我更改我的控制器文件之一时,什么都没有发生。所以我came across an article 提到我应该尝试将spring.devtools.restart.additional-paths=/src 添加到我的应用程序属性文件中。使用/src 将不起作用,因为它会认为这是一条绝对路径,所以我将其更改为仅src。之后,向我的控制器文件添加一个新端点并保存它会触发 Spring Boot 重启。但是,我得到了一个 404 端点,它只有在我手动重新启动服务器时才有效。
如何让 Spring Boot 重新启动并让我看到我对控制器所做的实际更改?
我在 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
【问题讨论】:
-
你用的是什么IDE?
-
@punkrocker27ka 我不使用任何 IDE。只是一个文本编辑器。我使用
./gradlew bootRun运行 Spring Boot
标签: spring-boot spring-boot-devtools