I have an existing Spring Boot project (1.4.3.RELEASE) and am trying to add some features using the Cloud AWS project. However, merely adding the dependency to the gradle build file causes an apparent cglib problem when instantiating one of my @Configuration classes.
Adding the following line to gradle build and running the app:
compile("org.springframework.cloud:spring-cloud-starter-aws-messaging:1.1.3.RELEASE")
Causes:
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]
It's complaining about not finding a non-empty constructor in my @Configuration class, but those are supported in latest version of Spring. The app boots up fine if I remove the dependency. How to fix this without reconfiguring my classes? Wait for an updated version of Cloud AWS?
You need to configure your app to use BOM dependencies to avoid dependency conflicts. BOMs are more like a maven feature (you can read up here) but the Spring folks have come up with a Gradle plugin to allow the same behavior. Look into this Spring Blog Post for a full explanation. But basically adding this to your gradle config:
You can then do:
On which you don't have to specify the actual dependency version for spring boot plugins.