我正在使用cdi-api-1.2依赖项,当使用 maven-jbehave-plugin 执行 jbehave 测试时,我注意到类是从 cdi -api-1.0而不是从 1.2 版本加载的。
经过一些研究后发现,cdi-api-1.0 依赖项是由 maven 本身($MAVEN_HOME/lib/)和 jbehave-maven-plugin 类路径的一部分提供的。
有没有人有类似的问题,并且知道如何解决这个类加载混乱?
// 萨沙
POM:
<dependencies>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core-example</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-weld</artifactId>
<version>4.1</version>
<exclusions>
<exclusion>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
<version>2.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.3.5.Final</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<executions>
<execution>
<id>unpack-view-resources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
<execution>
<id>embeddable-stories</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>**/JBehaveWeldStories.java</include>
</includes>
<ignoreFailureInStories>true</ignoreFailureInStories>
<ignoreFailureInView>true</ignoreFailureInView>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>