Rih*_*rds 3 java spring spring-3
如何在Java(Spring 3.1)中启用@Required注释?不是在xml中,而是在Java中.还有哪个注释我把这个启用?在@Feature下(在@FutureConfiguration或@Bean中(在@Configuration中)?
编辑:
@Feature
public MvcAnnotationDriven annotationDriven(ConversionService conversionService) {
return new MvcAnnotationDriven().conversionService(conversionService)
.argumentResolvers(new CustomArgumentResolver());
}
Run Code Online (Sandbox Code Playgroud)
这是否支持所有注释?
@ anubhava的答案有效,但他参考了Spring 2.0手册,该手册已有5年历史.
在XML配置中,Spring 3.x有一个更优雅的方法:<context:annotation-config/>.这也启用了您可能想要的其他一大堆功能,而RequiredAnnotationBeanPostProcessor只启用了一些功能.
请参见Spring 3.x手册.
如果您正在使用@Bean-style配置,那么@Required应该已经启用了注释,因为这是@Bean有效的.但是,这可能是一个错误 - Spring 3.1仍然处于早期测试阶段,其大部分可能会被打破.
除非你真的知道你在做什么,否则我强烈建议你坚持使用3.0.x.
| 归档时间: |
|
| 查看次数: |
820 次 |
| 最近记录: |