首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SpringApplication未被识别

SpringApplication未被识别
EN

Stack Overflow用户
提问于 2015-10-26 14:46:52
回答 2查看 77关注 0票数 1

我有以下代码:

代码语言:javascript
复制
public class Application {
public static void main(String[] args){
    SpringApplication.run(Application.class, args);
    }
}

但是Eclipse不能识别SpringApplication,也不能为它导入库。

build.gradle包含:

代码语言:javascript
复制
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'
}

我遗漏了什么吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-10-26 15:03:22

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

代码语言:javascript
复制
compile "org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE"

并添加

代码语言:javascript
复制
compile("org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE")

然后向你汇报最新情况

票数 1
EN

Stack Overflow用户

发布于 2015-10-26 15:11:51

对build.gradle文件进行了如下修改,以使其工作:

代码语言:javascript
复制
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'
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33348645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档