Angular WAR构建

时间:2017-11-10 11:16:38

标签: angular maven jboss war

我想为.war构建Angular 5应用程序并从JBoss部署并运行它。

我为.war建造了maven 5角应用程序。在JBoss部署期间出现错误,但我可以在WEB-INF中创建WebContent目录后进行部署,但无法访问该站点。我不确定我的POM / WEB.XML是否配置正确。

我正在使用 mvn compile war:war

进行构建

我没有Maven的经验,所以如果你能帮助我,我将非常感激。

的pom.xml

 <project 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.vdb</groupId>
<artifactId>vdb</artifactId>
<version>0.0.1</version>

<build>
 <plugins>

   <plugin>
     <artifactId>maven-clean-plugin</artifactId>
     <version>2.5</version>
     <configuration>
       <filesets>
         <fileset>
           <directory>dist</directory>
           <includes>
             <include>*</include>
           </includes>
         </fileset>
       </filesets>
     </configuration>
   </plugin>

   <plugin>
     <groupId>com.github.eirslett</groupId>
     <artifactId>frontend-maven-plugin</artifactId>
     <version>1.5</version>
     <executions>
       <execution>
         <id>install node and npm</id>
         <goals>
           <goal>install-node-and-npm</goal>
         </goals>
         <configuration>
           <nodeVersion>v8.9.1</nodeVersion>
           <npmVersion>5.5.1</npmVersion>
         </configuration>
       </execution>

       <execution>
         <id>npm install</id>
         <goals>
           <goal>npm</goal>
         </goals>
         <configuration>
           <arguments>install</arguments>
         </configuration>
       </execution>

       <execution>
         <id>prod</id>
         <goals>
           <goal>npm</goal>
         </goals>
         <configuration>
           <arguments>run-script prod</arguments>
         </configuration>
         <phase>generate-resources</phase>
       </execution>
     </executions>
   </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <webXml>.\WEB-INF\web.xml</webXml>   
            <webResources>
                <resource>
                    <!-- this is relative to the pom.xml directory -->
                    <directory>./dist/</directory>
                </resource>
            </webResources>
        </configuration>

    </plugin>

 </plugins>

和WEB.XML

<?xml version="1.0" encoding="ISO-8859-1" ?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>VDB WebApp</display-name>
<description>
</description>

<servlet>
    <servlet-name>VDBWeb</servlet-name>
    <servlet-class>vdb.Servlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>VDBServlet</servlet-name>
    <url-pattern>/vdb</url-pattern>
</servlet-mapping>

2 个答案:

答案 0 :(得分:0)

原来,servlet名称在并且需要匹配。我还尝试打开/ vdb,我需要转到/ warname。

答案 1 :(得分:0)

我们可以在使用ng build构建角度之后,使用以下命令分别为角度代码构建战争,然后导航到dist文件夹并执行

jar -cvf angularUI.war *