【发布时间】:2016-11-06 16:35:00
【问题描述】:
我正在尝试使用 Gradle 和 IntelliJ 完成 Spring Framework Restful Web 服务创建教程 (https://spring.io/guides/gs/rest-service/#scratch)。我已经严格遵守了所有内容,但对于 Spring、IntelliJ 和 Java 来说还是很陌生的,我不确定如何进一步调试我的问题。
当我尝试构建我的项目时,我收到一些错误,指出“Java:包 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'
}
}
只是想我会添加一些额外的信息。我仍然看到错误并且不确定原因,但我的项目确实报告构建成功。但是,当我尝试制作项目时,我收到注释不存在错误。
【问题讨论】:
-
您还遵循了 IntelliJ 和 Gradle spring.io/guides/gs/intellij-idea 的 IDE 步骤?
-
@judoole 这看起来像是将教程从 Spring 导入 IntelliJ 的演练。我试图自己从头开始构建它,所以这些似乎都不适用。
-
链接中的演练是针对这个确切的教程参考 spring.io/guides/gs/rest-service/#use-sts 我问的原因是这个错误看起来像是 IntelliJ 没有从 build.gradle 正确导入项目的错误
标签: java spring intellij-idea gradle spring-boot