Angular 2 and Spring Boot - Deploy to War

前端 未结 3 1450
长情又很酷
长情又很酷 2021-02-03 14:48

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.

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 15:21

    After doing a lot of searching, I came across the Maven War Plugin. This allowed me to pull in the necessary frontend files to the backend for the successful creation of my WAR file. The changes that need to be made are as follows:

    Backend pom.xml - after the description tags add:

    war
    

    Then, inside the build tags, inside plugins add this plugin:

      
        maven-war-plugin
        
          
            
              ../frontend/target/frontend
            
          
        
      
    

    Other than that, you can keep the existing pom.xml's the same as only the backend pom.xml needs include war packaging. It ended up being a rather simple answer.

    Also need to set the base-href in the package.json. Note "build":

    "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build": "ng build --base-href=\"./\""
    },
    

提交回复
热议问题