如何解决当我的应用程序依赖于依赖于不同micronaut版本的lib时,找不到匹配的micronaut-bom变体
plugins {
id "java-library"
id "maven"
id "com.jfrog.artifactory" version "4.9.8"
}
...
dependencies {
annotationProcessor platform("io.micronaut:micronaut-bom:2.0.0")
annotationProcessor "io.micronaut:micronaut-inject-java"
annotationProcessor "io.micronaut:micronaut-validation"
implementation platform("io.micronaut:micronaut-bom:2.0.0")
implementation "io.micronaut:micronaut-inject"
implementation "io.micronaut:micronaut-runtime"
implementation "javax.annotation:javax.annotation-api"
implementation "io.micronaut.security:micronaut-security"
runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
}
....
以及使用此lib的应用程序:
plugins {
id "net.ltgt.apt-idea" version "0.21"
id "com.github.johnrengelman.shadow" version "5.0.0"
id "application"
id 'com.bmuschko.docker-remote-api' version '6.6.0'
}
....
dependencies {
// Micronaut dependencies
annotationProcessor platform("io.micronaut:micronaut-bom:${micronautVersion}")
annotationProcessor "io.micronaut:micronaut-inject-java"
annotationProcessor "io.micronaut:micronaut-validation"
annotationProcessor "io.micronaut.data:micronaut-data-processor"
implementation platform("io.micronaut:micronaut-bom:${micronautVersion}")
implementation("com.acme:my-library:0.0.1-SNAPSHOT")
...
}
....
当app和lib之间的micronaut版本不同时(即使只有补丁版本),尝试构建时也会收到此消息:
Could not determine the dependencies of task ':implementation:shadowJar'.
> Could not resolve all dependencies for configuration ':implementation:runtimeClasspath'.
> Could not resolve io.micronaut:micronaut-bom:2.0.0.
required by:
project :implementation > com.acme:my-library:0.0.1-SNAPSHOT
> No matching variant of io.micronaut:micronaut-bom:2.0.2 was found. The consumer was configured to find a runtime of a library compatible with Java 11,packaged as a jar,and its dependencies declared externally but:
- Variant 'apiElements' capability io.micronaut:micronaut-bom:2.0.2:
- Incompatible because this component declares an API of a platform and the consumer needed a runtime of a library
- Other compatible attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Variant 'enforcedApiElements' capability io.micronaut:micronaut-bom-derived-enforced-platform:2.0.2:
- Incompatible because this component declares an API of an enforced platform and the consumer needed a runtime of a library
- Other compatible attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Variant 'enforcedRuntimeElements' capability io.micronaut:micronaut-bom-derived-enforced-platform:2.0.2 declares a runtime of a component:
- Incompatible because this component declares an enforced platform and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Variant 'runtimeElements' capability io.micronaut:micronaut-bom:2.0.2 declares a runtime of a component:
- Incompatible because this component declares a platform and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
我可能做错了,因为Gradle应该处理版本冲突。我想念什么?
解决方法
这是由于不推荐使用的“ maven”插件,该插件计划在Gradle 7.0中删除。
您应该删除此插件,并改用“ maven-publish”
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。