我有以下代码:
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class, args);
}
}
但是 Eclipse 无法识别 SpringApplication 并且无法为其导入库。
build.gradle
包含:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'spring-boot'
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'com.qas:proweb:1.0.0'
compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE"
testCompile 'junit:junit:4.11'
}
我缺少什么吗?
最佳答案
你有一个错误的依赖关系。尝试删除这个(不是从构建脚本依赖项,而是从项目依赖项):
compile "org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE"
并添加
compile("org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE")
然后只需更新您的部门即可
关于java - Spring应用程序无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33348645/