-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebMvcConfig.java
26 lines (21 loc) · 1.07 KB
/
WebMvcConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package jp.bass.springboot.vue.config;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
private final WebProperties webProperties;
private final SpaPageResourceResolver spaPageResourceResolver;
public WebMvcConfig(WebProperties webProperties, SpaPageResourceResolver spaPageResourceResolver) {
this.webProperties = webProperties;
this.spaPageResourceResolver = spaPageResourceResolver;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations(webProperties.getResources().getStaticLocations())
.resourceChain(webProperties.getResources().getChain().isCache())
.addResolver(spaPageResourceResolver);
}
}