开发者

Inject Handler into annotation controller

开发者 https://www.devze.com 2023-02-05 09:40 出处:网络
How can I inject handler into a annotation controller(@Controller) without using @Auto开发者_Go百科wire?You can of course always configure autowiring in XML:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消