【发布时间】:2018-07-07 10:44:52
【问题描述】:
我正在尝试在启用了实时重新加载但不启用应用程序重新启动的 Spring Boot 项目上设置新的资源位置。我可以添加其他资源,但是在新目录中所做的任何更改都会导致应用程序重新启动。
上面的documentation 看起来很轻。我一定是误解了什么。
我的布局是这样的:
- src
- main
- java
- resources
- static
- web
- dist
我的应用程序类如下所示:
@Bean
WebMvcConfigurer configurer () {
return new WebMvcConfigurerAdapter() {
@Override
public void addResourceHandlers (ResourceHandlerRegistry registry) {
registry.addResourceHandler("/dist/**")
.addResourceLocations(""file:web/dist/"")
.setCachePeriod(0);
}
};
}
public static void main(String[] args)
{
SpringApplication app = new SpringApplication(Application.class);
app.addListeners(new PropertyLogger());
Properties properties = new Properties();
properties.setProperty("spring.devtools.restart.additional-paths", "web/dist/");
properties.setProperty("spring.devtools.restart.additional-exclude", "/dist/**");
app.setDefaultProperties(properties);
app.run(args);
}
我已经阅读了几个类似的问题,这似乎是我能做的最好的。是否可以在没有完全重新启动应用程序的情况下在 dist 上启用实时重新加载?
顺便说一下,我的 IDE 是 IntelliJ。我开始怀疑 IntelliJ 是否需要排除 dist 目录。如果是这样,我会跟进。
【问题讨论】: