简体   繁体   中英

spring3 @autowired and @inject

i'm spring2.5, i normally use @autowired for DI. If i not wrong, in spring3, we can use @Inject for similar feature right? please comment. I tried to add @Inject instead of @autowired but doesnt work. need extra library?

If by "doesn't work" you mean that the annotation can't be resolved, then yes, you need a JSR-330 API library. You can download it here .

Or if you use maven:

<dependency>
  <groupId>javax.inject</groupId>
  <artifactId>javax.inject</artifactId>
  <version>1</version>
</dependency>

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