我使用的依赖项为:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
当我对 .java
文件进行更改时,开发工具工作正常,但当我对静态文件(.html 文件)进行更改时,开发工具无法工作。此外,当我重新加载页面时,没有看到更改。我必须重新启动应用程序才能看到更改。而且每次我进行一些小更改时都需要重新启动应用程序,这非常耗时。
最佳答案
在 spring-boot-maven-plugin 的 pom.xml 中添加以下配置:
<configuration>
<addResources>true</addResources>
</configuration>
如果您从命令行启动应用程序,上述内容将起作用。不过,请参阅这篇文章了解更多详细信息:Refreshing static content with Spring MVC and Boot
关于java - 当我更改静态文件并重新加载页面时,为什么 spring devtools 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57188141/