本文介绍了build.gradle不是设置文件定义的构建的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建Gradle文件并收到错误Build file '.../build.gradle' is not part of the build defined by settings file '.../settings.gradle'. If this is an unrelated build, it must have it's own settings file.

I'm trying to build a Gradle file and getting the error Build file '.../build.gradle' is not part of the build defined by settings file '.../settings.gradle'. If this is an unrelated build, it must have it's own settings file.

这是我的build.gradle:

Here is my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
    baseName = 'gs-securing-web'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-starter-web")
    // tag::security[]
    compile("org.springframework.boot:spring-boot-starter-security")
    // end::security[]
    testCompile("junit:junit")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("org.springframework.security:spring-security-test")
}

这是我的settings.gradle:

Here is my settings.gradle:

/*
 * This settings file was generated by the Gradle 'init' task.
 *
 * The settings file is used to specify which projects to include in your build.
 * In a single project build this file can be empty or even removed.
 *
 * Detailed information about configuring a multi-project build in Gradle can be found
 * in the user guide at https://docs.gradle.org/4.0/userguide/multi_project_builds.html
 */

/*
// To declare projects as part of a multi-project build use the 'include' method
include 'shared'
include 'api'
include 'services:webservice'
*/

rootProject.name = 'gs-securing-web'

我如何构建它?

推荐答案

我遇到了同样的问题.我看不到答案,尽管我迟到了,这可能对其他人有帮助.

I had same issue. I see there is no answer, though I'm late, this might be helpful for others.

从可用位置复制settings.gradle文件,然后将其粘贴到所需位置.

Copy the settings.gradle file from the available location and paste it and needed location.

在我的情况下,错误是-

In my case Error was -

* What went wrong:
Project directory '/Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects' is not part of the build defined by settings file '/Users/pradeepbehera/settings.gradle'. If this is an unrelated build, it must have its own settings file.

我从/Users/pradeepbehera/settings.gradle复制了settings.gradle文件并粘贴到/Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects.

I copied settings.gradle file from /Users/pradeepbehera/settings.gradle and pasted at /Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects.

然后就可以了.

这篇关于build.gradle不是设置文件定义的构建的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 13:46