Affects: spring-context:4.3.25.RELEASE
Team,
I am working on a project which uses external jars as dependencies. All these jars are built on top of spring-core. As, I integrate these jars in my application I am running into DuplicateBeanException
. Now, I do not have control on these third party libraries. In order to resolve this duplicate bean-name, I thought of using FullyQualifiedAnnotationBeanNameGenerator.class
. But FullyQualifiedAnnotationBeanNameGenerator.class
is available from 5.2.3.RELEASE
. My application runs on top of our wrapper framework. This wrapper framework internally brings in all the spring dependencies. And we are running lower version of spring. So, I do-not have access to increase the spring version as well. In this scenario, what is the alternative of FullyQualifiedAnnotationBeanNameGenerator.class
when my spring-context is 4.3.25.RELEASE
or lower
Comment From: snicoll
@arnabsarkardhn Sorry but Spring 4 is EOL so we can't provide support until you upgrade. When you do, you'll have access to this class.
Comment From: sbrannen
what is the alternative of
FullyQualifiedAnnotationBeanNameGenerator.class
when my spring-context is4.3.25.RELEASE
or lower
If you cannot upgrade to 5.2.3 or higher, the alternative is to implement your own custom AnnotationBeanNameGenerator
subclass that effectively does the same thing as FullyQualifiedAnnotationBeanNameGenerator
. If you take a look at FullyQualifiedAnnotationBeanNameGenerator
you'll see that the code is not complicated.
Comment From: arnabsarkardhn
@sbrannen Thank you. Yes, I am currently working on this solution.
But, still I see one concern. I see AnnotationBeanNameGenerator
runs on every packages wherever a class is marked @Component, @Repository, @Service, @Controller
.
I want to run the AnnotationBeanNameGenerator
on some specific packages names. Is it even possible?
For example:
I want to run AnnotationBeanNameGenerator
on these specific packages:
com.work.discovery
com.work.execution
com.helloworld.bidder
Comment From: sbrannen
I want to run the
AnnotationBeanNameGenerator
on some specific packages names. Is it even possible?
Sure. You can extend AnnotationBeanNameGenerator
, apply your custom logic to a set of packages that you control, and then simply delegate to the standard logic in AnnotationBeanNameGenerator
for all other packages.