I have a new angular2 project that was built using the standard file structure described in quickstart. I am trying to create an API gateway and have spring-boot host my application, however I was not able to configure the boot to use the / dist directory in my project where the created sources are created. The structure of the project is as follows:
project
|--dist
|--node_modules
|--src
| |--app
| |--assets
| |--main
| | |--java
| | |--resources
| | | |--config
| | |--webapp
| | | |--WEB-INF
I would like to use the default / dist directory so that I can use npm / webpack for continuous development in the user interface.
I tried to configure the static resource directory as follows:
spring.resources.staticLocations: /dist
But this does not seem to work.
I created a resource handler to point directly to the dist directory:
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
String currentPath = new File("./").getAbsolutePath();
currentPath = "file:///" + currentPath;
registry.addResourceHandler("/**").addResourceLocations(currentPath + "/dist/");
}
}
, URL ('/') index.html.
/ spring -boot, /dist project? ? , .