首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >输入META/MANIFEST.MF是重复的,但没有设置重复的处理策略。

输入META/MANIFEST.MF是重复的,但没有设置重复的处理策略。
EN

Stack Overflow用户
提问于 2022-11-23 23:30:24
回答 1查看 53关注 0票数 1

我正在尝试用一些API端点构建一个spring应用程序。每次我尝试运行"gradle build“时,都会出错:

代码语言:javascript
运行
复制
Entry META-INF/MANIFEST.MF is a duplicate but no duplicate handling strategy has been set.

以下是生成扫描的输出:

代码语言:javascript
运行
复制
3:23:01 pm: Executing 'build --scan'...

> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes
> Task :bootJarMainClassName
> Task :bootJar FAILED
4 actionable tasks: 3 executed, 1 up-to-date

Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service. Do you accept these terms? [yes, no] 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootJar'.
> Entry META-INF/MANIFEST.MF is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

build.gradle:

代码语言:javascript
运行
复制
plugins {
    id 'java'
    id 'org.springframework.boot' version '2.7.5'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

jar {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    manifest {
        attributes(
                'Main-Class': 'com.example.backendapp.BackendAppApplication'
        )
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

到目前为止我尝试过的解决方案:

  1. 在jar
  2. 中添加"duplicatesStrategy = DuplicatesStrategy.EXCLUDE“,将等级从7.5.1降至7.2
EN

回答 1

Stack Overflow用户

发布于 2022-11-23 23:51:56

可以通过将其添加到build.gradle中来解决这一问题:

代码语言:javascript
运行
复制
tasks.withType(Jar) {
   duplicatesStrategy = DuplicatesStrategy.EXCLUDE

   manifest {
      attributes["Main-Class"] = "com.example.backendapp.BackendAppApplication"
   }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74554033

复制
相关文章

相似问题

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