The @Resource annotation is part of the JSR-250 annotation collection and is packaged with Jakarta EE. This annotation has the following execution paths, listed by precedence:
Match by Name
Match by Type
Match by Qualifier
These execution paths are applicable to both setter and field injection.
The @Inject Annotation
The @Inject annotation belongs to the JSR-330 annotations collection. This annotation has the following execution paths, listed by precedence:
Match by Type
Match by Qualifier
Match by Name
These execution paths are applicable to both setter and field injection. In order to access the @Inject annotation, the javax.inject library has to be declared as a Gradle or Maven dependency.
The @Autowired Annotation
The behaviour of @Autowired annotation is similar to the @Inject annotation. The only difference is that the @Autowired annotation is part of the Spring framework. This annotation has the same execution paths as the @Inject annotation, listed in order of precedence:
Match by Type
Match by Qualifier
Match by Name
These execution paths are applicable to both setter and field injection.
These execution paths are applicable to both setter and field injection.
The
@Inject
AnnotationThe
@Inject
annotation belongs to the JSR-330 annotations collection. This annotation has the following execution paths, listed by precedence:@Inject
annotation, the javax.inject library has to be declared as a Gradle or Maven dependency.The
@Autowired
AnnotationThe behaviour of
@Autowired
annotation is similar to the@Inject
annotation. The only difference is that the@Autowired
annotation is part of the Spring framework. This annotation has the same execution paths as the @Inject annotation, listed in order of precedence:Match by Type Match by Qualifier Match by Name These execution paths are applicable to both setter and field injection.
来源: https://www.baeldung.com/spring-annotations-resource-inject-autowire