java - org.gradle.initialization.DefaultSettings_Decorated 无法转换为 org.gradle.api.internal.project.ProjectInternal

标签 java spring gradle spring-boot

我尝试创建 spring boot 应用程序:

我从https://start.spring.io/

中选择了我需要的组件

现在我想构建应用程序,但它失败了:

FAILURE: Build failed with an exception.

* Where: 
Settings file 'D:\objectsharingsystem\settings.gradle' line: 2

* What went wrong:
A problem occurred evaluating settings 'object-sharing-system'.
> Failed to apply plugin [id 'org.gradle.java']
   > org.gradle.initialization.DefaultSettings_Decorated cannot be cast to org.gradle.api.internal.project.ProjectInternal

* Try:   
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

settings.gradle:

rootProject.name = 'object-sharing-system'
apply plugin: 'java'
compileJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

build.gradle:

buildscript {
    ext {
        springBootVersion = '2.0.0.BUILD-SNAPSHOT'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

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


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-jdbc')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile('org.springframework.boot:spring-boot-starter-validation')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('com.microsoft.sqlserver:mssql-jdbc')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

请大家帮忙找错

最佳答案

settings.gradle 无法处理Project 级别插件的应用。

settings.gradle 中删除 apply plugincompileJava。 您已经在 build.gradle 中设置了 sourceCompatibility

关于java - org.gradle.initialization.DefaultSettings_Decorated 无法转换为 org.gradle.api.internal.project.ProjectInternal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42953816/

相关文章:

spring - junit 每行执行两次

gradle - gradle是否支持 “promotion”错误?

android - 如何在 Android 中创建可重用的 Activity?

Android Studio : Gradle Refresh Failed - Could not find com. android.tools.build :gradle:2. 2.0-alpha6

java - 如何使用最新版本的计费客户端正确导入 BillingResponse (billing :2. 0.1)

java - 在首次应用程序启动之前设置帐户的最佳方法

java - 如何使用 maven 和 jboss-as-maven-plugin 运行 JBoss 6.2 EAP 服务器?

json - @ControllerAdvice 无法返回 ResponseEntity<T>(T 是 POJO)

java - 在 EJB jar 中,在哪里放置代码以在初始化时只执行一次?

java - 从处理程序 android 调用 asynctask