简体   繁体   中英

Can I mix JEE and Spring annotations using Spring as CDI?

So, pretty straightforward question. Can I mix JEE annotations with Spring annotations on the same project? Are there any known issues with mixing both types of annotations?

For example, @Autowired and @Inject? @Named and @Qualifier?

Should Spring be able to solve injections without issues?

The reason I'm asking this is because I've encountered myself with some legacy code that uses Spring as CDI framework but 60% of the code uses JEE annotations. Some beans, however, are wired using @Autowired, there are also Spring ConfigProperties, etc.

I've already seen some weird behaviour, like classes not being injected, or @Named not being recognized by Spring, etc.

Spring does support CDI annotations, including @Inject, @Named, @Qualifier, ... But it comes with some limitations .

If some class is not injected, or @Named is not recognized, I think it is likely a configuration problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM