我正在使用Maven 3.2.3和Maven War 2.6插件。我希望Maven WAR插件的“inlace”目标默认执行(不需要在命令行中明确指定“war:inlace”)。所以我创建了一个包含以下内容的个人资料
<profile>
<id>dev</id>
<activation>
<property>
<name>!flag</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/src/main/webapp/WEB-INF/classes</directory>
</fileset>
<fileset>
<directory>${project.basedir}/src/main/webapp/WEB-INF/lib</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<useCache>true</useCache>
<workDirectory>/tmp/${project.artifactId}/war/work</workDirectory>
</configuration>
<goals>
<goal>inplace</goal>
</goals>
</plugin>
</plugins>
</build>
</profile>
使用“mvn help:active-profiles”,我已经验证了在我的WAR项目中运行“mvn clean install”时正在使用此配置文件。但是,WAR没有组装到位。例如,我得到输出
[INFO] Packaging webapp
[INFO] Assembling webapp [myproject] in [/Users/davea/Dropbox/workspace/myproject/target/myproject]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/davea/Dropbox/workspace/myproject/src/main/webapp]
[INFO] Webapp assembled in [17460 msecs]
另外我注意到我的src / main / resources / WEB-INF文件夹中没有“classes”或“lib”资源。我需要以不同的方式配置以使我的WAR就地构建?
答案 0 :(得分:0)
这可能被归类为How to get Maven to run war:exploded but not war:war的副本,但有一点点扭曲。而不是exploded
,它必须是inplace
:
<pluginManagement>
<plugins>
<plugin>
<!-- don't pack the war -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!-- optional, depends on your setup -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
</execution>
<execution>
<id>war-inplace</id>
<phase>package</phase>
<goals>
<goal>inplace</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
<pluginManagement>
答案 1 :(得分:-2)
WAR插件负责收集Web应用程序的所有工件依赖项,类和资源,并将它们打包到Web应用程序存档中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>