How can I inject handler into a annotation controller(@Controller
) without using @Auto开发者_Go百科wire
?
You can of course always configure autowiring in XML:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
default-autowire="byType">
<!-- all beans here will be autowired, including those
found by <contect:component-scan /> -->
</beans>
But you will probably have to supply Setter methods for the properties.
Reference: Autowiring Collaborators
BTW, you can also use the JSR-250 @Resource
annotation (and of course JSR-330's @Inject
, thanks @Bozho) if you don't want to use Spring's proprietary @Autowired
annotation.
Reference: @Resource
, @Autowired
and @Inject
精彩评论