2014-07-22 57 views

回答

0

此对象在应用方面使用singleton scope

<bean id="accountController" class="com.foo.DefaultAccountController" /> 

<!-- (singleton scope is the default) --> 
<bean id="accountService" class="com.foo.DefaultAccountService" /> 

然后你就可以自动装配在像这样的一些声明豆依赖性:

public class DefaultAccountController { 
    @Autowired 
    private DefaultAccountService accService; 

    ... 
} 

详细信息可以在Spring documentation找到。

+0

如何将该对象传递给其他类。 – user3060230

+0

@ user3060230我更新了答案 – injecto

相关问题