【发布时间】:2015-11-24 14:18:26
【问题描述】:
我正在使用带有 javax 注释 (JSR-330) 的 spring 4。在 Maven 中
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
所以我使用 @Named, @Inject 和 @Resource from javax.annotation.* from javax.inject.* 而不是 Spring @Autowire, @Component , ... Spring 很好地支持它们。很好的例子:http://www.mkyong.com/spring3/spring-3-and-jsr-330-inject-and-named-example/
我的问题是我不能在带有 javax 注释的会话范围内拥有一个 bean,所以我使用了 @Named 和 spring @Scope: org.springframework.context.annotation.Scope
我可以使用 javax 注释创建会话范围 bean 吗?!
【问题讨论】:
-
请查看我的回答。希望它能达到目的!
标签: java spring javax-inject