Spring Boot application is packaged as a fat jar file. I am utilizing the embedded Tomcat instance of Spring Boot. I did not alter the default locations in application.properties for spring.resources.static-locations. The production build for the Angular application is added under /static. server.servlet.context-path is set as app. server.port is 8480. base href for index.html is .
/static
- /assets
-- /images
---- logo.png
---- /flags
------ flag.png
-- /scss
- index.html
- *.js
- *.js.map
- *.ttf
- *.eot
- *.svc
- *.woff
- *.woff2
I can load the interface and the Angular application is properly sending REST requests but I cannot load any image resource. /assets/scss is properly recognized in Dev Tools but not /assets/images. Also added this @Configuration according to this video.
@Configuration
public class StaticResourceConfigurator extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/assets/images/**")
.setCachePeriod(0)
.addResourceLocations("classpath:/static/assets/images/");
}
}
Requests for image resources are sent to localhost:8480/assets/images/logo.png when it should be localhost:8480/app/assets/images/logo.png
I am using IntelliJ IDE. Here is the screenshot of my resources
ChromeDevTools log using production build application. Replaced app with afs
You should change the baseUrl of your index file as follows.
If your Jar name is app.jar, then your baseUrl has to be