For some reason bootstrap webjars are not being copied into target, and for that reason they cannot be found.
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
...
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.1.3</version>
</dependency>
Resource handlers:
@Configuration
@EnableWebMvc
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/*");
registry.addResourceHandler("/resources/").addResourceLocations("/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
Somewhere in my static resources
...
<script src="webjars/bootstrap/4.1.3/js/bootstrap.min.js"></script>
...
Nothing is generated into /target
Any idea what am I missing?
I spend few hours on this and also reached second page on google searches.
I will answer my own question.
I would never tell that could be a problem but apparently @GetMapping
annotation broke my UI. I still didn't figure it out what was the problem. I just found solution.
So I used Thymelea
f to resolve my views
@Controller
public class ViewController {
@GetMapping("/")
public String home() {
return "/home";
}
}
And apparently it clashes when I use traditional Restful controller
@RestController(value = "/face-detection")
public class FaceDetectController {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) {
...
This single @GetMapping
was breaking entire UI.
What I had to do was simply add /
in the mapping
@GetMapping(value ="/", produces = MediaType.APPLICATION_JSON_VALUE)
And the whole thing magically started to work. Similar issue somewhere deep in the github: https://github.com/springfox/springfox/issues/1647