Reinstate qualifier support for legacy JSR-330 @javax.inject.Named
annotation
#33345
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Affects: Spring Boot 3.2.5, Spring 6.1.6. Also tested with Spring Boot 3.2.8
We have a project which we have some modules using javax/Guice and others with Spring Boot. Now we're upgrading from Spring Boot 2.7.18 to 3.2.5, but we're having some problems related to
javax.inject.Named
.Our code has a "common" module with services/repositories which is used in both Guice and Spring Boot, and for that we're using
@Named/@Inject
in the classes.In version 2.7.18 all is working fine, but when we upgraded to 3.2.5 we started receiving an error when injecting dependencies on a class. The class has 2 parameters in the constructor, both of an interface and using
@Named("nameOfBean")
to distinguish between the expected implementation to be injected, and we have the two related implementations.I created a simple project to reproduce the problem and share with you. I tried changing some dependencies and nothing solved the problem.
I tried changing all to
jakarta.*
, and then all worked fine. But, that's not an option right now because of project context.The project is in https://github.com/marcioscharamtrustly/TestSpringBootJavax
A lille more about the problem: It appears that Spring identifies
@Named
and knows how to handle and inject it. But it doesn't work well when the parameters expect a@Named("name")
.And we're based on this issue: #31090
The error I'm receiving when running
TestSpringBootJavaxApplication
is:We also tested using
maven-compiler-plugin
3.13.0, setting the true as suggested here: https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retentionThe text was updated successfully, but these errors were encountered: