2017-05-20 12 views
0

私はresteasywildflyでrest-clientを構築しています。 stacktraceによると、おそらく私は依存関係に問題があります。 、変更スコープに関する削除や何かを持つ別のスタックトレースを除くすべての結果を与えるものではありませんのpom.xmlに依存関係を追加
まだ行って多くの試みが
はここに私のResteasy。クラスが見つからない

スタックトレース

です...見つかりません
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/core/GenericType 
    at groupId.Main.<init>(Main.java:33) 
    at groupId.Main.main(Main.java:36) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.core.GenericType 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 7 more 

のpom.xmlスタックトレースによると、あなたはIntelliJの中にmainメソッドを実行している

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
    JBoss, Home of Professional Open Source 
    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual 
    contributors by the @authors tag. See the copyright.txt in the 
    distribution for a full listing of individual contributors. 

    Licensed under the Apache License, Version 2.0 (the "License"); 
    you may not use this file except in compliance with the License. 
    You may obtain a copy of the License at 
    http://www.apache.org/licenses/LICENSE-2.0 
    Unless required by applicable law or agreed to in writing, software 
    distributed under the License is distributed on an "AS IS" BASIS, 
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    See the License for the specific language governing permissions and 
    limitations under the License. 
--> 
<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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
     <artifactId>restClient</artifactId> 
     <groupId>groupId</groupId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>rest-client</artifactId> 
    <packaging>war</packaging> 

    <name>restClient: WAR Module</name> 

    <url>http://wildfly.org</url> 
    <licenses> 
     <license> 
     <name>Apache License, Version 2.0</name> 
     <distribution>repo</distribution> 
     <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> 
     </license> 
    </licenses> 

    <dependencies> 

     <!-- Dependency on the EJB module so we can use it's services if needed --> 

     <!--&lt;!&ndash; https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs &ndash;&gt;--> 

     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-client</artifactId> 
     <version>3.1.2.Final</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>jaxrs-api</artifactId> 

      <scope>provided</scope> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs --> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jaxrs</artifactId> 
      <version>3.1.2.Final</version> 
      <scope>provided</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider --> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-multipart-provider</artifactId> 
      <version>3.1.2.Final</version> 
      <scope>provided</scope> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxb-provider --> 
     <!--<dependency>--> 
     <!--<groupId>org.jboss.resteasy</groupId>--> 
     <!--<artifactId>resteasy-jaxb-provider</artifactId>--> 
     <!--<version>3.1.2.Final</version>--> 
     <!--<scope>provided</scope>--> 
     <!--</dependency>--> 

     <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs --> 
     <!-- https://mvnrepository.com/artifact/javax.ejb/ejb-api --> 



     <!-- Import the CDI API, we use provided scope as the API is included in JBoss WildFly --> 
     <dependency> 
      <groupId>javax.enterprise</groupId> 
      <artifactId>cdi-api</artifactId> 
      <scope>provided</scope> 
     </dependency> 

     <!-- Import the JSF API, we use provided scope as the API is included in JBoss WildFly --> 
     <dependency> 
      <groupId>org.jboss.spec.javax.faces</groupId> 
      <artifactId>jboss-jsf-api_2.2_spec</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/javax.ejb/ejb-api --> 
     <dependency> 
      <groupId>javax.ejb</groupId> 
      <artifactId>ejb-api</artifactId> 
      <version>3.0</version> 
     </dependency> 

     <!-- Import the JPA API, we use provided scope as the API is included in JBoss WildFly --> 
     <!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.1-api --> 
     <dependency> 
      <groupId>org.hibernate.javax.persistence</groupId> 
      <artifactId>hibernate-jpa-2.1-api</artifactId> 

      <version>1.0.0.Final</version> 

     </dependency> 
     <!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api --> 
     <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <scope>provided</scope> 
      <exclusions> 
       <exclusion> 
        <groupId>dom4j</groupId> 
        <artifactId>dom4j</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <scope>provided</scope> 
      <exclusions> 
       <exclusion> 
        <groupId>dom4j</groupId> 
        <artifactId>dom4j</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <scope>provided</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> 
     <!--<dependency>--> 
     <!--<groupId>org.postgresql</groupId>--> 
     <!--<artifactId>postgresql</artifactId>--> 
     <!--<version>42.1.0</version>--> 
     <!--</dependency>--> 

     <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --> 
     <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider --> 
     <dependency> 
      <groupId>com.fasterxml.jackson.jaxrs</groupId> 
      <artifactId>jackson-jaxrs-json-provider</artifactId> 
      <version>2.9.0.pr3</version> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-xml-provider --> 
     <dependency> 
      <groupId>com.fasterxml.jackson.jaxrs</groupId> 
      <artifactId>jackson-jaxrs-xml-provider</artifactId> 
      <version>2.9.0.pr3</version> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> 
     <dependency> 
      <groupId>commons-io</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>2.5</version> 
     </dependency> 

    </dependencies> 

    <build> 
     <finalName>${project.artifactId}</finalName> 
     <plugins> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>${version.war.plugin}</version> 
      <configuration> 
       <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! --> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     </plugins> 
    </build> 

</project> 

答えて

0

すべてのあなたのRESTEasyの依存関係は「提供された」とマークされています。つまり、アプリケーションは、ランタイムコンテナ(たとえば、アプリケーションサーバ)がそれらを提供することを期待していることを意味する。 IntelliJは実行時にこれらの依存関係を提供しないため、ClassNotFoundExceptionエラーが発生します。

https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

を提供これは非常に、コンパイルのようなものですが、あなたはJDK またはコンテナは、実行時に依存関係を提供することを期待を示しています。たとえば、 Java Enterprise Edition用のWebアプリケーションを構築する場合、 は、Webコンテナがこれらのクラスを提供するため、Servlet APIおよび関連するJava EE APIへの依存関係を スコープに設定します。この スコープは、コンパイルおよびテストのクラスパスでのみ使用でき、 は推移しません。

IntelliJでアプリケーションをテストするには、指定されたスコープを削除するだけです。

関連する問題