Bibek Khadka :
In my Spring MVC project I had
<mvc:resources mapping="/resources/**" location="/WEB-INF/resources/, file:${catalina.home}/myresources/" />
configured to serve static resources from multiple locations. In Spring Boot however,
@Configuration
public class ResourceConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/", "file:${catalina.home}/myresources/");
}
}
is not working as expected. Please help.
Bibek Khadka :
@Configuration
public class ResourceConfig implements WebMvcConfigurer {
private static final Log LOG = LogFactory.getLog(ResourceConfig.class);
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
String catalinaHome;
try {
catalinaHome = System.getenv("CATALINA_HOME");
} catch (Exception e) {
LOG.error(e);
catalinaHome = "";
}
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/", "file:" + catalinaHome + "/myresources/");
}
}