2017-07-10 67 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"> 
基本路徑
相關問題