Sunday, August 26, 2012

Unsatisfied dependency expressed through constructor argument with index 1 of type [int]: Could not convert constructor argument value of type [java.lang.String]

if you get this in spring:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'internalHttpServer' defined in class path resource [my.xml]: 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: "${port}"
while you were trying to instantiate a spring bean with a few arguments. the reason might be that you first define the bean and only then reference the properties file, so it would just try to enter "${port}" into the value of the int. it did not recognize the port because the property files reference was defined after the bean definition. bum...