2017-07-10 45 views
1

我必须用maven和Glassfish服务器构建并提供angular2应用程序。我有一个java EE后端。如何在java EE后端maven build和glassfish server上运行Angular2应用程序?

App structure looks like this

enter image description here

而且pom.xml的是这样的:

http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0。 0 ro.nttdata 候选人 0.0.1-SNAPSHOT 战争 候选人 SRC 个 Maven的编译器插件 3.6.1 1.8 1.8 Maven的战争插件 3.0.0 的WebContent

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


     <plugin> 
      <groupId>com.github.eirslett</groupId> 
      <artifactId>frontend-maven-plugin</artifactId> 
      <version>1.3</version> 

      <configuration> 
       <nodeVersion>v6.10.1</nodeVersion> 
       <npmVersion>4.4.1</npmVersion> 
       <workingDirectory>candidate-client/</workingDirectory> 
      </configuration> 

      <executions> 
       <execution> 
        <id>install node and npm</id> 
        <goals> 
         <goal>install-node-and-npm</goal> 
        </goals> 
       </execution> 

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

       <execution> 
        <id>npm run build</id> 
        <goals> 
         <goal>npm</goal> 
        </goals> 

        <configuration> 
         <arguments>run build</arguments> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <id>copy-client-build</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>copy-resources</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>target/${project.artifactId}/</outputDirectory> 
         <overwrite>true</overwrite> 
         <resources> 
          <resource> 
           <directory>candidate-client/dist/</directory> 
           <includes> 
            <include>*/**</include> 
            <include>*.html</include> 
           </includes> 
          </resource> 
         </resources> 
        </configuration> 
       </execution> 
      </executions> 
      </plugin> 



    </plugins> 

</build> 
<dependencies> 

    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>7.0</version> 
    </dependency> 
    <dependency> 

     <groupId>org.glassfish.jersey.core</groupId> 

     <artifactId>jersey-server</artifactId> 

     <version>2.10.4</version> 


    </dependency> 
    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>eclipselink</artifactId> 
     <version>2.6.4</version> 
    </dependency> 
    <dependency> 

     <groupId>org.glassfish.jersey.media</groupId> 

     <artifactId>jersey-media-json-jackson</artifactId> 

     <version>2.25.1</version> 


    </dependency> 
</dependencies> 

我设法建立生成dist文件夹并移动fi的应用程序到目标为止,但是当我在服务器上运行它时,我得到了404。我是新的maven ...我很感谢每一个建议。

回答

0

pom配置看起来不错。

在您的index.html文件,你需要添加像

<base href="/appname"> 
基本路径
相关问题