2014-07-18 61 views
1

我有對RESTEasy JAX RS Client編譯器沒有找到一個類我有隨着Maven依賴

我增加一條,作爲一個依賴於我的項目這樣的相關性的代碼:

<dependency> 
    <groupId>org.jboss.resteasy</groupId> 
    <artifactId>resteasy-client</artifactId> 
    <version>3.0.8.Final</version> 
</dependency> 

我通常可以寫代碼,但是當我嘗試編譯,我得到這些錯誤:

java: cannot access javax.ws.rs.client.ClientBuilder 
    class file for javax.ws.rs.client.ClientBuilder not found 

java: cannot access javax.ws.rs.core.Link 
    class file for javax.ws.rs.core.Link not found 

java: cannot access javax.ws.rs.client.WebTarget 
    class file for javax.ws.rs.client.WebTarget not found 

雖然我通常可以找到這些類,我知道他們是在我的Maven的回購協議,如果我找一找全光照g我的IDE,我可以訪問它們,所以我知道它們存在。

我試着將依賴範圍改爲providedcompile只是爲了測試它,但沒有運氣。

任何想法可能會失蹤?

編輯

相關的pom.xml

<modelVersion>4.0.0</modelVersion> 

<artifactId>my-project-id</artifactId> 
<name>MyProject Name</name> 

<dependencies> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-mapper-asl</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.httpcomponents</groupId> 
     <artifactId>httpclient</artifactId> 
     <version>4.2.1</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-client</artifactId> 
     <version>3.0.8.Final</version> 
     <scope>provided</scope> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

類無法編譯

import org.jboss.resteasy.client.jaxrs.ResteasyClient; 
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; 
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; 
import my.project.representations.App; 

public class Main { 

    public static void main(String[] args) { 

     ResteasyClient client = new ResteasyClientBuilder().build(); 
     ResteasyWebTarget target = client.target(SERVER_URL); 

     String token = "access_token"; 

     target.register(new BearerTokenFilter(token)); 

     Admin admin = target.proxy(Admin.class); 

     Realm realm = admin.realm("realm_name"); 

     for (App app : realm.apps().findAll()) { 
      System.out.println(app.getName()); 
     } 

    } 

} 
+0

你是如何編譯的? – Fabian

+0

我用IDE(IntelliJ IDEA)編譯了它,當我看到這個錯誤時,我嘗試通過maven'mvn clean install'編譯,它顯示了相同的問題 –

+0

請儘可能'.pom'和一個源代碼失敗的源文件,如果可能的話最小的失敗的例子。 – Fabian

回答

5

您還沒有包括依賴於它是什麼抱怨:

這就是API類:

<dependency> 
    <groupId>javax.ws.rs</groupId> 
    <artifactId>javax.ws.rs-api</artifactId> 
    <version>2.0</version> 
</dependency> 

search.maven.org是你的朋友!

以下內容也不正確。

你已經標記resteasy-client.jar依賴,以及其他人,你需要爲provided,這意味着它會執行或在包裝時被包含在類路徑中。

刪除所有這些依賴關係中的<scope>元素,這很可能是不正確的。

檢查<scope>元素文檔,並確保這是你的意圖。

+1

我試着添加'jaxrs-api'和'resteasy-jaxrs',它的工作原理很奇怪,因爲我認爲我不必這樣做 –

相關問題