标签:lse ali 区别 group repos autowire epo ota end
@Resource
(JSR250)和@Inject
(JSR330)[Java规范的注解]AutowiredAnnotationBeanPostProcessor
完成解析自动装配功能@Autowired
一样实现自动注入功能,默认是按照组件名称进行装配的。@Primary
功能,没有支持@Autowired(required = false)
@Inject
需要导入javax.inject
依赖才能使用,和@Autowired
功能一样,但没有required=false
属性值设定。@Autowired
是Spring定义的,@Resource
和@Inject
都是Java的规范<!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
// @Autowired(required = false)
// @Qualifier("bookRepository")
// @Resource(name = "bookRepository")
@Inject
private BookRepository bookRepository2;
标签:lse ali 区别 group repos autowire epo ota end
原文地址:https://www.cnblogs.com/Grand-Jon/p/10040014.html