Spring appears to be recommending the same class twice as potentially qualifying for autowiring: once as myDateTimeFormatter
and another as io.company.thirdparty.MyDateTimeFormatter
? Why does Spring see the same class as these two different options? I’d like Spring to simply autowire so I can call myDateTimeFormatter.myFoo()
inside my Spring Boot Starter app. Has anyone ever seen similar behavior before? How can I configure Spring to recognize that both of these are actually the same class and just used it to autowire the bean?
I have no control over the code inside third-party-1.2.3-SNAPSHOT.jar
.
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method myFoo in io.company.thirdparty required a single bean, but 2 were found:
- myDateTimeFormatter: defined in URL [jar:file:/Users/me/.m2/repository/io/company/thirdparty/1.2.3-SNAPSHOT/third-party-1.2.3-SNAPSHOT.jar!/io/company/thirdparty/MyDateTimeFormatter.class]
- io.company.thirdparty.MyDateTimeFormatter: defined in URL [jar:file:/Users/me/.m2/repository/io/company/thirdparty/1.2.3-SNAPSHOT/operate-common-1.2.3-SNAPSHOT.jar!/io/company/thirdparty/MyDateTimeFormatter.class]
This may be due to missing parameter name information
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Ensure that your compiler is configured to use the '-parameters' flag.
You may need to update both your build tool settings as well as your IDE.
(See https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention)
You need to sign in to view this answers
Leave feedback about this