【问题标题】:Unable to import spring-boot gradle project in eclipse workspace无法在 Eclipse 工作区中导入 spring-boot gradle 项目
【发布时间】:2016-07-20 23:43:00
【问题描述】:

Spring-boot 应用程序的 Gradle 设置:build.gradle 文件我使用了我的所有 java 源文件所在的 sourcesSet。

 buildscript {
        repositories {
            //Required repos
            mavenCentral()
            maven { url "http://repo.spring.io/snapshot" }
            maven { url "http://repo.spring.io/milestone" }
        mavenLocal()
        }
        dependencies {
            //Required dependency for spring-boot plugin
            classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.2.BUILD-SNAPSHOT'
        }
    }

    apply plugin: 'java'
    apply plugin: 'war'
    apply plugin: 'spring-boot'
    apply plugin: 'eclipse-wtp'

    bootRepackage { 
         mainClass = 'com.test.app.Application'
    }

    war {
        baseName = 'companies'
        version =  '0.1'
    }

    repositories {
        mavenCentral()
        maven { url "http://repo.spring.io/snapshot" }
        maven { url "http://repo.spring.io/milestone" }
        mavenLocal()
    }

    dependencies {
        compile 'org.springframework.boot:spring-boot-starter-web'
        //Required dependency for JSP
        providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper'
    }

    sourceSets {
        main {
            java {
                srcDir 'app/GeneratedSource'
                srcDir 'app/JavaSource'
                srcDir 'web/JavaSource'
            }
            resources {
                srcDir 'app/GeneratedSource'
                srcDir 'app/JavaSource'
                srcDir 'web/JavaSource'
            }
        }
    }

    eclipse { 
        classpath {
            defaultOutputDir = file('web/WebContent/WEB-INF/classes')
        }
    }

    webAppDirName = 'web/WebContent'
    libsDirName = 'war'

    war {
        baseName = baseName
        version = appVersion
        archiveName = warName
    }

    task printClasspath {
        doLast {
            configurations.testRuntime.each { println it }
        }

在此处输入图片描述Command Line able to build model When in eclipse while importing gradle project it is showing error

我无法在 Eclipse 中导入 Gradle 项目

【问题讨论】:

    标签: eclipse gradle spring-boot


    【解决方案1】:

    你有 eclipse 的 Gradle 插件吗?

    帮助 -> Eclipse MArketplace -> 搜索“Gradle” -> 安装 Gradle STS 集成。

    此外,我建议您将 Spring Boot 版本更改为“1.3.3.RELEASE”。

    buildscript {
    ext {
        springBootVersion = '1.3.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
    }}
    

    【讨论】:

    • 是的,我正在使用 Gradle,我正在使用 Eclipse Luna 版本:Mars Release (4.5.0),
    • 谢谢@bor 为我工作...我可以知道是什么问题吗?
    • 通常情况下,Eclipse 使用 Maven 比使用 Gradle 更好,所以我提出了三个可能的问题:你没有插件,你拥有的插件是旧的,或者你的 Spring Boot 版本足够新。
    【解决方案2】:

    在我的例子中,gradle 插件有一个可用的更新。一旦我使用 Eclipse Marketplace 更新了插件,一切正常,并且项目已正确导入。

    【讨论】:

      猜你喜欢
      • 2018-10-27
      • 2013-01-25
      • 2020-06-19
      • 2020-09-25
      • 1970-01-01
      • 2018-09-29
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      相关资源
      最近更新 更多