【发布时间】:2011-05-11 08:07:28
【问题描述】:
我的 spring bean 有一个带有唯一强制参数的构造函数,我设法使用 xml 配置对其进行了初始化:
<bean name="interfaceParameters#ota" class="com.company.core.DefaultInterfaceParameters">
<constructor-arg>
<value>OTA</value>
</constructor-arg>
</bean>
然后我就这样用这个bean,效果很好。
@Resource(name = "interfaceParameters#ota")
private InterfaceParameters interfaceParameters;
但我想用 annocations 指定构造函数 arg 值,例如
@Resource(name = "interfaceParameters#ota")
@contructorArg("ota") // I know it doesn't exists!
private InterfaceParameters interfaceParameters;
这可能吗?
提前致谢
【问题讨论】:
-
或许答案给了here。
标签: spring annotations