2016-07-04 2 views
1

Gradle과 IntelliJ를 사용하여 Spring Framework Restful Web Service 작성 자습서 (https://spring.io/guides/gs/rest-service/#scratch)를 사용해 보려고합니다. 나는 편지에 모든 것을 따라 갔지만 Spring, IntelliJ 및 Java에 대해 상당히 새로운 것이므로 일반적으로 내 문제를 디버깅하는 방법을 알지 못합니다.IntelliJ에서 Spring RestService 자습서를 만들 수 없습니다.

프로젝트를 빌드 할 때 "Java : package org.springframework.web.bind.annotation이 없습니다."라는 오류 메시지가 나타납니다. 라이브러리 참조가 누락 된 것 같지만 확인하고 포함하는 방법을 잘 모르겠습니다.

buildscript { 
    ext { 
     springBootVersion = '1.3.5.RELEASE' 
    } 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath("org.springframework:spring-web:${springBootVersion}") 
    } 
} 

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

jar { 
    baseName = 'hello_springtest' 
    version = '0.0.1-SNAPSHOT' 
} 

repositories { 
    mavenCentral() 
} 

sourceCompatibility = 1.8 
targetCompatibility = 1.8 

dependencies { 
    compile('org.springframework.boot:spring-boot-starter-web') 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.3' 
} 

eclipse { 
    classpath { 
     containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 
     containers  'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' 
    } 
} 

방금 ​​추가 정보를 추가한다고 생각했습니다. 나는 여전히 오류를보고 있는데 왜 확신 할 수 없지만 프로젝트에서 빌드가 성공적이라고보고합니다. 그러나 프로젝트를 만들려고 할 때 주석을받지 못하면 오류가 발생합니다.

+0

또한 IntelliJ 및 Gradle https://spring.io/guides/gs/intellij-idea/에 대한 IDE 단계를 따라 했습니까? – judoole

+0

@judoole 그래서 스프링에서 IntelliJ로 자습서를 가져 오기위한 연습과 같이 보입니다. 나는 처음부터 끝까지 걷고 그것을 만들려고 시도 했으므로 그 중 아무 것도 실제로 적용되지 않는 것 같습니다. –

+0

링크의 연습은이 튜토리얼의 정확한 참조입니다. https://spring.io/guides/gs/rest-service/#use-sts 제가 물었던 이유는 IntelliJ가 오류를 가져 오지 못했기 때문입니다. – judoole

답변

0

당신은 빌드 스크립트에 어떤 의존성이 있습니다. 이것은 중복 된 것으로 보이고 Gradle은 추가 의존성을 찾게됩니다.

은 그냥 buildscript 종속성 나는 당신의 buildscript 내에서 그것을 사용하는 이유를 볼

classpath("org.springframework:spring-web:${springBootVersion}") 

에서이 종속성을 제거합니다.

+0

@ Stansilav 당신은 맞을 것입니다. 그것은 내가 놓친 것을 찾으려고 시도한 것일뿐입니다. 내가 그 라인을 제거했지만 안타깝게도 프로젝트를 만들 때 동일한 빌드 오류가 발생합니다. –

+0

'spring-boot-starter-web'은'org.springframework.web.bind.annotation' 패키지가 지정된'spring-web'에 의존하기 때문에 이상합니다. 모든 의존도가 아직 다운로드되지 않았기 때문에 프로젝트를 업데이트해야합니까? 또는'--refresh-dependencies' 플래그를 사용하여 실행하십시오. – Stanislav

관련 문제