我运行测试:
@RunWith(Arquillian.class) 公共类GreeterTest {
@Inject
Greeter greeter;
@Deployment
public static JavaArchive createDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
.addClass(Greeter.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
System.out.println(jar.toString(true));
return jar;
}
@Test
public void should_create_greeting() {
Assert.assertEquals("Hello, Earthling!",
greeter.createGreeting("Earthling"));
greeter.greet(System.out, "Earthling");
}
package com.teste;
import java.io.PrintStream;
公共阶层Greeter {
public void greet(PrintStream to, String name) {
to.println(createGreeting(name));
}
public String createGreeting(String name) {
return "Hello, " + name + "!";
}
我的pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 COM 泰斯特 0.0.1-SNAPSHOT org.jboss.arquillian 的Arquillian-BOM 1.1.5.Final POM 进口
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>1.1.5.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
</dependencies>
但是会导致错误。
java.lang.NoClassDefFoundError:javax / ejb / Stateless 在org.jboss.arquillian.container.weld.ee.embedded_1_1.mock.Ejbs.findEjbs(Ejbs.java:38)...
任何人都知道可以做什么? 谢谢!
答案 0 :(得分:3)
我找到了问题的解决方案,添加了一些依赖项。
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>test</scope>
<version>1.0.2.Final</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<scope>test</scope>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
答案 1 :(得分:0)
如果您正在做EE事情。您可以引入整个依赖而不是单个依赖。
<dependency>
<groupId>org.apache.tomee</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0-3</version>
</dependency>