首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >build.gradle不是由设置文件定义的构建的一部分。

build.gradle不是由设置文件定义的构建的一部分。
EN

Stack Overflow用户
提问于 2019-05-24 12:56:29
回答 7查看 32.5K关注 0票数 23

我正在尝试构建一个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.

这是我的build.gradle:

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

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

我怎样才能建造这个呢?

EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2019-12-17 09:54:57

我也有同样的问题。我看没有答案,虽然我迟到了,但这可能对其他人有帮助。

从可用位置复制settings.gradle文件并粘贴它和需要的位置。

我的错误是-

代码语言:javascript
复制
* 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复制/Users/pradeepbehera/settings.gradle文件并粘贴到/Users/pradeepbehera/Downloads/ud867-master/1.04-Demo-GroovyClosuresAndObjects

然后一切都很顺利。

票数 12
EN

Stack Overflow用户

发布于 2020-04-21 22:19:58

我也遇到了同样的问题:

'Users/Shared/myProject/theDirectory/settings.gradle.:项目目录‘User/Shared/myProject/theDirectory/src/test不是由设置文件定义的构建的一部分

问题是,我从一个终端窗口运行gradle,该窗口在目录结构中的基础太低。

修复:只需更改终端窗口cd ..中的目录

因此,对我来说,我只是将目录级别备份到:"myProject“文件夹和boom...simple gradle工作。

票数 43
EN

Stack Overflow用户

发布于 2020-04-06 11:22:44

我最近也遇到了同样的问题,这也使我想到了这个问题。

在我的例子中,我试图从错误的路径‘./project/someFolder’构建jar,并将我的路径更正为‘./project’。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56293162

复制
相关文章

相似问题

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