繁体   English   中英

Spring Cloud AWS cglib问题

[英]Spring Cloud AWS cglib issue

我有一个现有的Spring Boot项目(1.4.3.RELEASE),正在尝试使用Cloud AWS项目添加一些功能。 但是,仅将依赖项添加到gradle构建文件中会在实例化我的@Configuration类之一时引起明显的cglib问题。

将以下行添加到gradle构建并运行应用程序:

compile("org.springframework.cloud:spring-cloud-starter-aws-messaging:1.1.3.RELEASE")

原因:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.***.application.config.AwsConfig$$EnhancerBySpringCGLIB$$5301ed81]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.***.application.config.AwsConfig$$EnhancerBySpringCGLIB$$5301ed81.()
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]

它抱怨在我的@Configuration类中找不到一个非空的构造函数,但是最新版本的Spring支持这些构造函数。 如果删除依赖项,应用程序启动正常。 如何解决此问题而无需重新配置我的课程? 等待Cloud AWS的更新版本?

您需要将您的应用程序配置为使用BOM依赖关系,以避免依赖关系冲突。 BOM更像是一个maven功能(您可以在此处阅读),但是Spring人员已经提出了Gradle插件来允许相同的行为。 查看此Spring Blog Post以获取完整说明。 但基本上将其添加到您的gradle配置中:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:1.0.0.RC1"
  }
}

apply plugin: "io.spring.dependency-management"

然后,您可以执行以下操作:

dependencyManagement {
  imports {
    mavenBom 'org.springframework.boot:spring-boot-starter-parent:1.4.2.RELEASE'
  }
}

dependencies {
  compile "org.springframework.boot:spring-boot-starter-web"
}

您不必在其上为Spring Boot插件指定实际的依赖版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM