2

Eclipse 无法识别我的 JSF-Apache Myfaces/Spring/Hibernate 项目中的 @Inject。

我试图在setter方法上使用它来注入对我在Spring容器中注册为@Component @SessionScoped的类的引用。

是什么赋予了?我似乎在我的 POM 中定义了最新版本的 Spring。

4

1 回答 1

5

@Inject is not a Spring annotation, but an annotation brought about by JSR-330. It is an annotation that Spring supports and it is synonymous with the @Autowired annotation.

You have to make sure that you have the jar that contains @Inject, because it is not a part of the standard JDK. You can download the jar from here, or you can use this maven dependency:

<dependency>
  <groupId>javax.inject</groupId>
  <artifactId>javax.inject</artifactId>
  <version>1</version>
</dependency>
于 2012-04-05T15:10:20.193 回答