2013-09-01 76 views
0

我正在學習Arquillian平臺。爲了做我使用Eclipse的例子。我第一次成功地遵循
http://arquillian.org/guides/getting_started/
,之後,我試圖做的代碼示例
http://arquillian.org/guides/testing_java_persistence/
但我有庫的依賴的煩惱:「測試Java持久性」指南中缺少依賴關係

import org.jboss.arquillian.container.test.api.Deployment; 
import org.jboss.arquillian.junit.Arquillian; 

不被認可的Eclipse。

這是的pom.xml文件

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>org.arquillian.example</groupId> 
    <artifactId>arquillian-tutorial</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>arquillian-tutorial</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-all</artifactId> 
     <version>1.8.5</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.hamcrest</groupId> 
     <artifactId>hamcrest-integration</artifactId> 
     <version>1.2.1</version> 
    </dependency> 
    <dependency> 
     <groupId>net.avh4.util</groupId> 
     <artifactId>imagecomparison</artifactId> 
     <version>0.0.2</version> 
     <scope>test</scope> 
    </dependency> 
     <dependency> 
     <groupId>org.jboss.spec</groupId> 
     <artifactId>jboss-javaee-6.0</artifactId> 
     <version>1.0.0.Final</version> 
     <type>pom</type> 
     <scope>provided</scope> 
    </dependency> 
     <dependency> 
     <groupId>org.jboss.arquillian</groupId> 
     <artifactId>arquillian-bom</artifactId> 
     <version>1.1.1.Final</version> 
     <scope>import</scope> 
     <type>pom</type> 
    </dependency> 
    <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> 
</project> 
+0

我認爲你已經執行了'mvn eclipse:eclipse'?此外,類org.jboss.arquillian.container.test.api.Deployment包含在以下工件中:org.jboss.arquillian.container:arquillian-container-test-api。這似乎沒有明確定義你的POM,你可以嘗試添加它看看是否有幫助。 – DB5

+0

我用maven導入了項目來日食,我用答案n.1解決了問題 –

回答

3

的BOM的Arquillian應該存在在你的POM的dependencyManagement部分中dependency,而不是作爲一個普通的dependendcy,就像這樣:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    ... 
    <dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>org.jboss.arquillian</groupId> 
     <artifactId>arquillian-bom</artifactId> 
     <version>1.1.1.Final</version> 
     <scope>import</scope> 
     <type>pom</type> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 
    ... 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    ... 
    <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> 
    ... 
    </dependencies> 
</project> 

請注意使用Arquillian BOM和arquillian-junit-container依賴項(其版本通過BOM指定)。不使用Arquillian BOM將需要您指定arquillian-junit-container依賴項的版本。其他要求的缺陷是junit:junit和一個Arquillian容器適配器(在你的情況下,Weld嵌入容器適配器)。