首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以在Spring中使用参数注入方法?

是否可以在Spring中使用参数注入方法?
EN

Stack Overflow用户
提问于 2012-04-28 16:50:25
回答 1查看 8.1K关注 0票数 4

从医生那里:

在包含要注入的方法(在本例中为CommandManager )的客户端类中,要“注入”的方法必须具有以下形式的签名:

代码语言:javascript
复制
<public|protected> [abstract] <return-type> theMethodName(no-arguments);

是否存在解决这一限制的方法?

EN

回答 1

Stack Overflow用户

发布于 2012-04-28 17:02:30

是的你可以。下面是spring的一个示例,http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html

代码语言:javascript
复制
 @Autowired
 public void prepare(MovieCatalog movieCatalog,
                   CustomerPreferenceDao customerPreferenceDao) {
   this.movieCatalog = movieCatalog;
   this.customerPreferenceDao = customerPreferenceDao;
 }
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10365560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档