我必须使用maven和Glassfish服务器构建和提供angular2应用程序。我有一个java EE后端。
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 网页内容
<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文件夹并将文件移动到目标文件的应用程序,但是当我在服务器上运行它时,我得到了404.我是maven的新手...我很感谢每一个建议
答案 0 :(得分:0)
pom配置看起来很好。
在index.html文件中,您需要添加基本路径,例如
<base href="/appname">