I have application.properties file and I successfully get String values from it with @Value. I am having problems getting an int from it.
jedisHostName=127.0.0.1
redisPort=6379
In my config class I have
@Value("${jedisHostName}")
private String hostName;
and it works fine, but when I try to
@Value("#{new Integer.parseInt('${redisPort}')}")
private Integer redisPort;
I get
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'secret***': Unsatisfied dependency expressed through field 'redisPort';
I am also trying only
@Value("#{new Integer('${redisPort}')}")
but I get same exception. I am even trying to simply do a
@Value("${redisPort}")
private String redisPort;
int jedisPort = Integer.parseInt(redisPort.trim());
but then I get
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'secret***' defined in file [secret***.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate **** Constructor threw exception; nested exception is java.lang.NullPointerException
I have normal class names but I use "secret***" just for the example