我有一个属性文件test.properties
HOST = http://localhost
PORT = 1234
在我的配置文件中,我将属性文件中的值传递给bean构造函数arg。
<util:properties id="nodeProperty"
location="classpath:config/test.properties" />
<context:property-placeholder
properties-ref="nodeProperty" />
<bean id="client" class="com.abc.client.ReadWrite">
<constructor-arg value="${HOST}" index="0"/>
<constructor-arg value="${PORT}" index="1" type="int"/>
</bean>
当我运行时,我收到以下错误
Unsatisfied dependency expressed through constructor argument with index 1 of type
[int]: Could not convert constructor argument value of type [java.lang.String] to
required type [int]: Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "8002;"
答案 0 :(得分:0)
查看错误消息的结尾 - 对于输入字符串:“8002;” 我认为PORT属性值不正确。