Let me just start off by saying, I am new to Maven / Spring and am having a hard time figuring out what to do when my directory does not follow the preferred Maven structure. >
Hello i use Angular 4 and Spring boot to deploy war. It's work fine and i share it.
Here pom.xml :
4.0.0
com.example
Spring_Angular
0.0.1-SNAPSHOT
jar Spring_Angular
Demo project for Spring Boot
org.springframework.boot
spring-boot-starter-parent
2.0.2.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
org.apache.maven.plugins
maven-war-plugin
${basedir}/target/angular4Client
com.github.eirslett
frontend-maven-plugin
1.6
v8.9.2
5.6.0
target
${basedir}/src/main/angular4client
install node and npm
install-node-and-npm
v8.9.2
5.6.0
npm install
npm
install
npm build
npm
run build
org.apache.maven.plugins
maven-resources-plugin
copy-resources
validate
copy-resources
${basedir}/target/classes/static/
${basedir}/src/main/angular4Client/dist/angular4Client
target/angular4Client
static
Then in your angular package.json change like this:
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
Create a proxy.conf.json file in angular project root :
{
"/api": {
"target": "http://localhost:8080",
"secure": false
}
}
And last things to do, move your angular 4 project into : "src/main/" on SpringBoot project.
Good luck according to this demo : http://javasampleapproach.com/java-integration/integrate-angular-4-springboot-web-app-springtoolsuite