我有一个 Spring Boot 应用程序,我想更改前端的目录。与其将前端资源放在目录resources/static
内,我想将它们移动到resources
之外的另一个目录。我需要更改哪些属性,以便我的应用程序考虑用于呈现前端的新目录?
您可以使用WebMvcConfigurerAdapter
配置其他资源映射:
@Component
public class ResourcesMvcAdapter extends WebMvcConfigurerAdapter {
private final Path resourcePath = Paths.get( ... );
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations(resourcePath.toUri().toString());
}
}