简体   繁体   English

Angular Project在Tomcat上Maven战争文件

[英]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. 我的公司希望启动一个新的Angular项目,并被告知将Angular项目作为War File进行部署,因此可以将其上载到我们拥有的工件中,并且可以轻松地部署到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? 在我看来,这是太多的开销,为什么要为Web客户端使用Java格式?

Just to understand, the backend Java Code is seperated, so in the end my App will only contain JavaScript, HTML and CSS. 仅了解一下,后端Java代码是分开的,因此最终我的App仅包含JavaScript,HTML和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. 因此,我已经使用IntelliJ创建了一个空的Maven项目,并创建了一个新文件夹,并在其中使用CLI创建了一个新的Angular项目。

And this is my pom.xml inside the Angular project folder, so far: 到目前为止,这是我在Angular项目文件夹中的pom.xml:

    <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 据我了解,我需要将HTML等复制到

target/WEB-INF/classes 目标/ WEB-INF /类

folder, am I right? 文件夹,对吗? but my Maven file will not do that. 但是我的Maven文件不会这样做。 It will create a new folder inside target, so it looks like: 它将在目标内部创建一个新文件夹,如下所示:

target/maventest 目标/ maventest

In there I have a META-INF and a WEB-INF folder. 在那里,我有一个META-INF和一个WEB-INF文件夹。

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 据我了解,我需要将HTML等复制到

target/WEB-INF/classes 目标/ WEB-INF /类

folder, am I right? 文件夹,对吗?

No, you are not. 不,你不是。 The target folder will be generate automatically after maven process finish. Maven处理完成后,将自动生成目标文件夹。 The folder is also deleted if you run the command 如果运行命令,该文件夹也将被删除

mvn clean

This web project's folder structure is created by maven: 该Web项目的文件夹结构由maven创建:

在此处输入图片说明

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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