我将一个 Dropwizard
项目导入到 Intellij IDEA
中(使用项目本身的 Gradle Wrapper
)。它对其他人有用,但我最终遇到了这样的问题:
这是 gradle 依赖的要点。
https://gist.github.com/vineelya/d882bbd0885fafba785ca58f106dfc8b
线程“main”中的异常 java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
dependencies {
compile (
'io.dropwizard:dropwizard-core:' + dropwizardVersion,
'io.dropwizard:dropwizard-hibernate:' + dropwizardVersion,
'io.dropwizard:dropwizard-migrations:' + dropwizardVersion,
'io.dropwizard:dropwizard-auth:' + dropwizardVersion,
'io.dropwizard:dropwizard-assets:' + dropwizardVersion,
'io.dropwizard:dropwizard-forms:'+ dropwizardVersion,
最佳答案
您有两个依赖项正在导入旧版本的 Jackson Core
。
com.amazon.alexa:alexa-skills-kit:1.2
com.google.api-client:google-api-client:1.19.1
虽然 Gradle 应始终选择最新版本,但这可能会导致您的错误。
因此,使用排除它们
implementation('com.amazon.alexa:alexa-skills-kit:1.2') {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
}
implementation('com.google.api-client:google-api-client:1.19.1') {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
}
或者,将它们更新到兼容的(可能是最新的)版本(例如,参见 MavenCentral )。
要强制解决特定版本,您可以使用
configurations.all {
resolutionStrategy {
force 'com.fasterxml.jackson.core:jackson-core:2.8.8'
}
}
关于java - DropWizard Gradle 构建的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55009341/