有没有办法在Spring引导应用程序中发布Web内容而无需重新启动整个应用程序?
我使用thymeleaf试图将“spring.template.cache”属性设置为false但没有运气
答案 0 :(得分:2)
如果使用spring.template.cache
运行应用程序,设置mvn spring-boot:run
就足够了。
我不确定其他IDE,但是如果要运行Intellij IDEA的应用程序以刷新Thymeleaf模板,则需要制作项目(Cmd+F9
在Mac上)每次你想看到变化。
答案 1 :(得分:0)
如果你正在构建jar文件,那么首先将jar改为build.gradle中的war作为fallows:
apply plugin: 'war'
War{
baseName= 'projectName'
version='0.1.0'
}
在依赖关系
中添加以下语句providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
在控制器包中添加此类。
public class ServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
它对我有用..