BeanDefinitionOverrideException using sleuth-3.1.0-RC1
oburgosm opened this issue · 3 comments
I have a library that need an optional dependency with spring-cloud-sleuth and another dependency with datasource-proxy-spring-boot-starter
for some datasources customizations. This work for me until I updated to sleuth 3.1.0-RC1. I get a bean name collision between classes defined in:
- org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.DataSourceProxyConfiguration
- com.github.gavlyukovskiy.boot.jdbc.decorator.dsproxy.DataSourceProxyConfiguration
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'proxyDataSourceBuilderConfigurer' defined in class path resource [org/springframework/cloud/sleuth/autoconfig/instrument/jdbc/DataSourceProxyConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.DataSourceProxyConfiguration; factoryMethodName=proxyDataSourceBuilderConfigurer; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/sleuth/autoconfig/instrument/jdbc/DataSourceProxyConfiguration.class]] for bean 'proxyDataSourceBuilderConfigurer': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.github.gavlyukovskiy.boot.jdbc.decorator.dsproxy.DataSourceProxyConfiguration; factoryMethodName=proxyDataSourceBuilderConfigurer; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/github/gavlyukovskiy/boot/jdbc/decorator/dsproxy/DataSourceProxyConfiguration.class]] bound.
There is a plan to avoid this name collision to allow that both artifacts can be used in the same application?
Hi,
It seems a good part of this project has been rolled into Sleuth, hence the collisions.
https://docs.spring.io/spring-cloud-sleuth/docs/3.1.0/reference/html/integrations.html#sleuth-jdbc-integration
I got it to work again by removing this starter, adding p6spy normally and configuring p6spy using the Sleuth properties.
It seems to ignore my spy.properties for some reason
Hope that helps
Hi @oburgosm, @david-kerwick, it's correct, most of this project was copied to spring-cloud-sleuth with very few changes. Most notable is that logging will be disabled by default (spring.sleuth.jdbc.datasource-proxy.query.enable-logging=false
) since it doesn't make much sense to do that by default in tracing context. All other configurations were migrated to spring.sleuth.jdbc
and tracing span names were also changed, but overall everything should work.
There is a plan to avoid this name collision to allow that both artifacts can be used in the same application?
I was planning to add graceful delegation logic, but I couldn't get some time to do that yet.
It seems to ignore my spy.properties for some reason
I can also take a look at that when I have time, do you have any sample code to reproduce that?
Hi,
Thanks, I was wrong about the spy.properties
. I thought setting spring.sleuth.jdbc.datasource-proxy.query.enable-logging=true
would enable it and the appenders it contained. But once I set spring.sleuth.jdbc.p6spy.enable-logging=true
everything works as expected.