简体   繁体   中英

Angular Project To Maven War File On Tomcat

My company wants to start a new Angular project, and I am told to deploy the Angular Project as a War File, so it can be uploaded in the artifactory we have and it can easily be deployed to Tomcat 8.

However I have not much knowledge about War Projects. In my view it is too much overhead, why would you use a Java Format for a Web Client?

Just to understand, the backend Java Code is seperated, so in the end my App will only contain JavaScript, HTML and CSS.

So I have created an empty Maven Project with IntelliJ, created a new folder in which I created a new Angular Project with the CLI.

And this is my pom.xml inside the Angular project folder, so far:

    <project xmlns = "http://maven.apache.org/POM/4.0.0"
         xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test.maventest</groupId>
  <artifactId>wartest</artifactId>


  <version>1.0-SNAPSHOT</version>
  <name>wartest</name>
  <packaging>war</packaging>


  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <build>
    <finalName>maventest</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
          <webResources>
            <resource>
              <directory>dist</directory>
            </resource>
          </webResources>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

As far as I understood, I need to copy my HTML and so on in the

target/WEB-INF/classes

folder, am I right? but my Maven file will not do that. It will create a new folder inside target, so it looks like:

target/maventest

In there I have a META-INF and a WEB-INF folder.

Now how can I accomplish this, it must be easy in my view..

As far as I understood, I need to copy my HTML and so on in the

target/WEB-INF/classes

folder, am I right?

No, you are not. The target folder will be generate automatically after maven process finish. The folder is also deleted if you run the command

mvn clean

This web project's folder structure is created by maven:

在此处输入图片说明

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM