SpringApplication无法识别

时间:2015-10-26 14:46:52

标签: java spring gradle spring-boot

我有以下代码:

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'
}

我缺少什么?

2 个答案:

答案 0 :(得分:1)

你有一个错误的依赖。尝试删除这个(不是来自构建脚本依赖项,而是来自项目的):

compile "org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE"

并添加

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

然后只需更新你的代表

答案 1 :(得分:0)

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-starter-web:1.2.5.RELEASE"

    testCompile 'junit:junit:4.11'
}