我正在尝试做这样的事情:
<bean id="myBean" class="com.example.SomeThing">
<property name="longValue">
<bean class="java.lang.Long">
<constructor-arg value="0x0418a14372d4186eL" type="long"/>
</bean>
</property>
</bean>
但这导致以下异常:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'java.lang.Long#19190b75' defined in file [/apollo/env/path/to/config.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
答案 0 :(得分:1)
我认为您需要factory-method
的{{1}}参数:
<bean>
(注意缺少“L”后缀。)
答案 1 :(得分:1)
您可以使用Java @Configuration
吗?
@Configuration
public class Config {
@Bean
public SomeThing someThing() {
final SomeThing bean = new SomeThing();
bean.set(Long.parseLong("0418a14372d4186e", 16));
return bean;
}
}
答案 2 :(得分:0)
SPeL应该工作
<bean id="myBean" class="com.example.SomeThing">
<property name="longValue" value="#{0x0418a14372d4186eL}" />
</bean>