Angular2 spring - load project structure

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? ? , .

+4
2

@chrylis webpack /dist ( Gradle).

/resources/**, .war . , include/exclude , , .js.

:

project  
|--build
|  |--dist
|  |--...  
|--node_modules
|--src  
|  |--app  
|  |--assets
|  |--main  
|  |  |--java  
|  |  |--resources
|  |  |  |--config  
|  |  |--webapp
|  |  |  |--WEB-INF  

WebMvcConfigurerAdapter , dist build:

spring.resources.static-locations: "file:./build/dist/"  

Webpack, Spring -Boot .

+1

Spring - :

/META-INF/resources/

/resources/

/static/

/public/

src/main/resources

index.html, , spring - .

src/main/resources/META-INF/resources/index.html

src/main/resources/resources/index.html

src/main/resources/static/index.html

src/main/resources/public/index.html
+2

Source: https://habr.com/ru/post/1657214/


All Articles