[英]Spring boot devtools with Spring mvc
是否可以在Spring MVC
項目中使用spring-boot-devtools
?
我基本上希望.jsp
頁面和其他 static 資源在不重啟服務器的情況下自動重新加載。
試試這些:添加一個配置 bean 並查看您的 jsp 文件是否正在加載
@Configuration
class WebMvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/dist/*.js").addResourceLocations(
"file:src/main/dist/"
);
}
}
或者在 pom.xml 中,連同 spring-boot-maven-plugin 添加這個
<configuration>
<addResources>true</addResources>
</configuration>
我不確定您將 static 內容放在類路徑中的什么位置,可能在 src/main/resources/public 文件夾中。 而是將它們放在 src/main/webapp 中,與其他任何 Java web 應用程序相同。 嵌入的 Tomcat 會在它們更改時自動重新加載它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.