2016-09-20 3 views
-1

안녕하세요. 현재 스프링 응용 프로그램에서 테스트를 실행하는 중 오류가 발생했습니다.Spring and Jetty NoClassDefFound 오류

오류 : 이건 내 처음으로 봄을 사용 받는다는됩니다

java.lang.ClassNotFoundException: org/eclipse/jetty/util/FutureCallback 

그래서 나는 매우 혼란 스러워요.
내 POM 파일에 문제가 있다고 생각하지만 확실하지 않습니다. 여기 내 pom.xml 파일입니다 :

<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</groupId> 
<artifactId>CountdownCustomer</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 

<name>CountdownCustomer</name> 
<url>http://maven.apache.org</url> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.4.0.RELEASE</version> 
</parent> 

<properties> 
    <java.version>1.8</java.version> 
    <servlet.container.port>10000</servlet.container.port> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
</properties> 
<dependencies> 
<dependency> 
    <groupId>org.jboss.resteasy</groupId> 
    <artifactId>resteasy-jackson-provider</artifactId> 
    <version>3.0.12.Final</version> 
</dependency> 
<dependency> 
    <groupId>org.jboss.resteasy</groupId> 
    <artifactId>resteasy-jaxrs</artifactId> 
    <version>3.0.12.Final</version> 
</dependency> 
<dependency> 
    <groupId>org.jboss.resteasy</groupId> 
    <artifactId>resteasy-client</artifactId> 
    <version>3.0.12.Final</version> 
</dependency> 
<dependency> 
    <groupId>org.jboss.resteasy</groupId> 
    <artifactId>jaxrs-api</artifactId> 
    <version>3.0.12.Final</version> 
</dependency> 
<dependency> 
    <groupId>org.jboss.resteasy</groupId> 
    <artifactId>resteasy-servlet-initializer</artifactId> 
    <version>3.0.12.Final</version> 
</dependency> 
<!-- Hibernate --> 
<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-entitymanager</artifactId> 
</dependency> 
<!-- H2 embedded database. --> 
<dependency> 
    <groupId>com.h2database</groupId> 
    <artifactId>h2</artifactId> 
</dependency> 
<!-- Spring --> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-data-rest</artifactId> 
    <exclusions> 
     <exclusion> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-tomcat</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-data-jpa</artifactId> 
    <exclusions> 
     <exclusion> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-tomcat</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-test</artifactId> 
    <scope>test</scope> 
    <exclusions> 
     <exclusion> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-tomcat</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-jetty</artifactId> 
</dependency> 
<dependency> 
    <groupId>com.jayway.jsonpath</groupId> 
    <artifactId>json-path</artifactId> 
    <scope>test</scope> 
</dependency> 
<!-- Junit --> 
<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <scope>test</scope> 
</dependency> 
</dependencies> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <skip>true</skip> 
      </configuration> 
      <executions> 
       <execution> 
        <id>surefire-it</id> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <skip>false</skip> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-maven-plugin</artifactId> 
      <version>9.1.4.v20140401</version> 
      <configuration> 
       <httpConnector> 
        <port>${servlet.container.port}</port> 
       </httpConnector> 
       <webApp> 
        <contextPath>/</contextPath> 
       </webApp> 
       <scanIntervalSeconds>10</scanIntervalSeconds> 
       <stopKey>foo</stopKey> 
       <stopPort>9999</stopPort> 
       <stopWait>1</stopWait> 
      </configuration> 
      <executions> 
       <execution> 
        <id>start-jetty</id> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <scanIntervalSeconds>0</scanIntervalSeconds> 
         <daemon>true</daemon> 
        </configuration> 
       </execution> 
       <execution> 
        <id>stop-jetty</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>stop</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

<repositories> 
    <repository> 
     <id>spring-releases</id> 
     <url>https://repo.spring.io/libs-release</url> 
    </repository> 
</repositories> 
<pluginRepositories> 
    <pluginRepository> 
     <id>spring-releases</id> 
     <url>https://repo.spring.io/libs-release</url> 
    </pluginRepository> 
</pluginRepositories> 

업데이트 :

문제는 당신이 다음 종속성을 추가해야 더 최근의

답변

0

에 부두 버전을 변경하여 고정하여 프로젝트 :

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util --> 
<dependency> 
    <groupId>org.eclipse.jetty</groupId> 
    <artifactId>jetty-util</artifactId> 
    <version>9.3.10.v20160621</version> 
</dependency> 
0

글쎄, 스프링 부트는 Tomcat을 다음과 같이 포함하고 있습니다. 임베디드 서버, 당신은 또한 당신이 그 부트 모든 종속성이 필요하지 않습니다 부두

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-jetty</artifactId> 
</dependency> 

와 함께 그 의존성을

<exclusions> 
    <exclusion> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-tomcat</artifactId> 
    </exclusion> 
</exclusions> 

를 제거하고 교체해야합니다. spring-boot-starter-data-rest에 이미 spring-boot-starter-data-jpaspring-boot-starter-web이 포함되어있는 경우이를 삭제할 수도 있습니다.

+0

이 변경 사항을 적용한 후 내 응용 프로그램이 돌풍을 일으키고 있지만 테스트를 실행할 때 동일한 오류가 발생합니다. – t77

+0

'spring-boot-starter-test' 종속성에서도 동일한 변경을 수행해야합니다. – rorschach

+0

그 예외를 추가했으나 여전히 테스트에서 실패합니다. – t77

0

jar 파일에 사용중인 클래스가 있는지 확인하십시오. 저장소 (C : \ Users \ .m2 \ repository)를 열면 jar 위치로 이동하고 jar 파일을 열고 볼 수 있습니다. 해당 jar에 클래스가 없으면 해당 클래스가있는 다른 종속성을 찾아 pom.xml에 추가하십시오.