我有一个简单的Maven应用程序,我使用Maven构建(只需清理安装)。
应用程序是从maven webapp原型开始生成的。
在构建和生成战争时,我希望src / main / resources及其所有内容都包含在.war中,但这并不会发生。
我在我的pom.xml中使用以下构建
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:1)
我使用了maven-archetype-webapp,pom是:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.greg</groupId>
<artifactId>ear-example</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.greg</groupId>
<artifactId>example-war</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>example-war Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>example-war</finalName>
</build>
</project>
我添加了一个图像和属性文件
$ find src/
src/
src/main
src/main/resources
src/main/resources/test.img
src/main/resources/test.properties
src/main/webapp
src/main/webapp/index.jsp
src/main/webapp/WEB-INF
src/main/webapp/WEB-INF/web.xml
jar tvf target/example-war.war
0 Thu Jan 19 15:28:18 GMT 2017 META-INF/
134 Thu Jan 19 15:28:16 GMT 2017 META-INF/MANIFEST.MF
0 Thu Jan 19 15:28:18 GMT 2017 WEB-INF/
0 Thu Jan 19 15:28:18 GMT 2017 WEB-INF/classes/
57 Thu Jan 19 15:24:40 GMT 2017 index.jsp
0 Thu Jan 19 15:28:16 GMT 2017 WEB-INF/classes/test.img
0 Thu Jan 19 15:28:16 GMT 2017 WEB-INF/classes/test.properties
222 Thu Jan 19 15:24:40 GMT 2017 WEB-INF/web.xml
0 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/
0 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/com.greg/
0 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/com.greg/example-war/
875 Thu Jan 19 15:26:00 GMT 2017 META-INF/maven/com.greg/example-war/pom.xml
116 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/com.greg/example-war/pom.properties