0

I have a properties file test.properties

HOST = http://localhost
PORT = 1234

In my config file I am passing the values from the properties file to a bean constructor-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>

When I run this I get the following error

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;"
  • 5
    Do you have semicolon in your port property? You dont need to specify type, spring will auto convert it. Also please paste actual input dont manipulate it. – SMA Dec 30 '14 at 05:57

1 Answers1

0

Look at the end of error message - For input string: "8002;" I think it is incorrect value for PORT property.

Oleg
  • 443
  • 3
  • 13