我试图用Maven从我的最终WAR文件中排除测试类。 通常情况下,如果我的测试在src / test / java中,它应该默认完成,但在我的情况下它没有这样做。 测试类在WEB-INF \ test-classes文件夹中编译 所以我在pom.xml中添加了以下插件
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<packagingExcludes>**/test-classes/*.class</packagingExcludes>
</configuration>
</plugin>
但即便如此,我的测试类仍然包含在最终的.war文件中 有没有人有解决方法或可以解释我错过了什么? 感谢
更新:我在我的pom.xml中使用的插件
<pluginManagement>
<plugins>
<!-- fix clean issue where duplicated entries of pom are created-->
<!--https://bugs.eclipse.org/bugs/show_bug.cgi?id=405915-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/META-INF</directory>
<includes>
<include>**/pom.properties</include>
<include>**/pom.xml</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<goals>
<goal>bind</goal>
</goals>
<versionRange>[1.2.6,)</versionRange>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<goals>
<goal>enhance</goal>
</goals>
<versionRange>[2.2.2,)</versionRange>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<goals>
<goal>run</goal>
</goals>
<versionRange>[1.8,)</versionRange>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- toolchain plugin to use specific JDK
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.8</version>
<vendor>ibm</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<!-- <forceJavacCompilerUse>true</forceJavacCompilerUse>-->
</configuration>
</plugin>
<!-- OPENJPA -->
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<includes>com/dsv/express/persistence/domain/*.class</includes>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<persistenceXmlFile>${project.basedir}${persistenceXmlFile-Path}</persistenceXmlFile>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
答案 0 :(得分:0)
问题是我使用maven package
目标,但不包括集成测试。运行m vn install
解决了我的问题!感谢