java - Spring应用程序无法识别

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

我缺少什么吗?

最佳答案

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

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/

相关文章:

java - 继续获取: Neither BindingResult nor plain target object for bean name 'index' available as request attribute

c# - C# 中的 TestNG 类似框架

java - Spring 从实体访问属性的方式是什么?

gradle - Eclipse JDT LS 和 Gradle - 资源异常 "Invalid project description"

maven - 从gradle安装MVN

java - 转动屏幕时 DatePicker Fragment 泄漏

spring - 是否可以将 web.xml 中的 .properties 文件与 contextConfigLocation 参数结合使用?

java - Spring MVC : Spring Security 4 doesn't intercept

android - 迁移到BOM后如何使用Maven-Publish Gradle插件生成Maven Pom

java - 如何从 Android WebView 进行 google 登录并在成功登录后重定向回主网站?