2015-01-22 2 views
0
내가하려고 할 때 내가

캔트 사용 스프링 부팅 스타터 웹 dependecies 테스트를 실행할 때

이 프로젝트는 그러나 잘

을 Gradle을을 사용하여 멀티 모듈 프로젝트 (웹, 일반, 배치)를 실행 한

봄 내가이 얻을 나오면 배치 모듈의 테스트 폴더에서의 JUnit을 실행

<batch>gradle -q dependencies --configuration testRuntime 
: 나는 배치 모듈에서 종속성 트리를 확인
Caused by: java.lang.NoClassDefFoundError: org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter 

뭐가 잘못

buildscript { 
    repositories { 
     maven { url "http://repo.spring.io/libs-release" } 
     mavenLocal() 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:$project.ext.springBootVersion") 

    } 
} 

description = 'batch' 

dependencies { 
    compile("org.springframework.boot:spring-boot-starter-batch:$project.ext.springBootVersion") 
    testRuntime("org.springframework.batch:spring-batch-test:$project.ext.springBatchVersion") { 
     exclude(module: 'spring-test') 
     exclude(module: 'spring-jdbc') 
     exclude(module: 'commons-io') 
     exclude(module: 'commons-collections') 
    } 

    /* compile ('org.springframework.integration:spring-integration-core:4.1.2.RELEASE')*/ 
    compile project(":common") 
    testRuntime("org.springframework.boot:spring-boot-starter-web") 

} 

어떤 생각 :

내가 buttom의에서 볼 가져올하는 동안 스프링 부팅 - 시작 - 웹

..... 
| |   +--- com.caucho:resin-hessian:4.0.23 
| |   +--- org.springframework:spring-jdbc:3.1.0.RELEASE -> 4.1.4.RELEASE (*) 
| |   +--- com.adobe.blazeds:blazeds-common:3.2.0.3978 
| |   +--- com.adobe.blazeds:blazeds-proxy:3.2.0.3978 
| |   +--- org.codehaus.jackson:jackson-core-asl:1.9.2 
| |   +--- org.codehaus.jackson:jackson-mapper-asl:1.9.2 (*) 
| |   \--- org.mockito:mockito-all:1.9.5 
| +--- com.mycompany.services.configuration:ConfigurationManager:2.0.8 (*) 
| +--- com.caucho:resin-hessian:4.0.23 
| +--- mysql:mysql-connector-java:5.1.34 
| \--- javax.inject:javax.inject:1 
+--- org.springframework.boot:spring-boot-starter-test:1.2.1.RELEASE 
| +--- junit:junit:4.12 
| | \--- org.hamcrest:hamcrest-core:1.3 
| +--- org.mockito:mockito-core:1.10.8 
| | +--- org.hamcrest:hamcrest-core:1.1 -> 1.3 
| | \--- org.objenesis:objenesis:2.1 
| +--- org.hamcrest:hamcrest-core:1.3 
| +--- org.hamcrest:hamcrest-library:1.3 
| | \--- org.hamcrest:hamcrest-core:1.3 
| +--- org.springframework:spring-core:4.1.4.RELEASE (*) 
| \--- org.springframework:spring-test:4.1.4.RELEASE 
|   \--- org.springframework:spring-core:4.1.4.RELEASE (*) 
+--- org.springframework.batch:spring-batch-test:3.0.2.RELEASE 
| +--- junit:junit:4.11 -> 4.12 (*) 
| +--- org.hamcrest:hamcrest-all:1.3 
| \--- org.springframework.batch:spring-batch-core:3.0.2.RELEASE (*) 
\--- org.springframework.boot:spring-boot-starter-web: FAILED 

이 배치 모듈 내 build.gradle입니다 실패 ?

감사합니다.

+0

런타임 또는 컴파일 타임에 필요합니까? – Opal

+0

런타임. 컴파일 할 때 아무런 문제가 없지만 테스트를 실행하고 스프링 컨테이너가 생기면 예외가 발생합니다. 파기 후에 나는 그 방법이 spring-boot-starer-web 의존의 내부에 있다는 것을 알았다. – rayman

+0

프로젝트를 온라인에서 사용할 수 있습니까? – Opal

답변

1

내 (응축) 예입니다하거나 적용해야 스프링 부트 플러그인 (당신은 플러그인을 빌드 스크립트 의존성으로 선언했지만 그것을 적용한 것으로 보이지는 않습니다).

스프링 부트 플러그인을 적용하면 자동으로 spring-boot-starter-web 버전이 플러그인과 동일한 버전으로 설정됩니다. 문서에서 플러그인이 설정할 수있는 list of all the versions을 볼 수 있습니다.

+0

제안한대로 버전을 제공했습니다. 여전히 같은 오류. compile ("org.springframework.boot : spring-boot-starter-web : $ project.ext.SpringBootVersion ") – rayman

+0

'gradle -dependencies'가 지금 말한 것은 무엇인가? 이전에'org.springframework.boot : spring-boot-starter-web : FAILED' (누락 된 버전 번호를 적어 두었습니다. 번호, 이제는 org.springframework.boot와 같아야합니다 : spring-boot-starter-web : 1.2.1.RELEASE' –

+0

당신은 그 사람을 못 박았습니다! 작동합니까? – rayman

1

옵션의 몇 가지 변경 :

testRuntime("org.springframework.boot:spring-boot-starter-web")

로는 :

compile("org.springframework.boot:spring-boot-starter-web")

또한, 내 봄 부팅 build.gradle 파일은 :$project.ext.springBatchVersion 변수를 사용하지 않습니다. 잘 변수를 설정하는 것 - 예를 들어, 여기 build.gradle 파일 : 당신이 중 하나를 당신이 의존성을 선언하고 버전 번호를 제공해야

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 

repositories { 
    mavenCentral() 
} 

dependencies { 
    compile("org.springframework.boot:spring-boot-starter-web") 
    compile("org.springframework.boot:spring-boot-starter-actuator") 
    testCompile("junit:junit") 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.2.1' 
} 
+0

testRuntime으로 액츄에이터 의존성을 추가했을 때 의존성 트리를 gradle로 다시 실행할 때 실패했습니다 : + --- org.springframework.boot : spring-boot-starter -web : FAILED + --- org.springframework.boot : spring-boot-starter-actuator : FAILED – rayman

+1

다음 단계는 @Opal과 같은 온라인 프로젝트를 찾는 것입니다. 오류가 발생하는 최소한으로 줄이면 도움이 될 것입니다. 다른 사람들이 그것을 만들 수있는 것으로 밝혀지면 구성 문제 일 수 있습니다. – mnd

관련 문제