Spring Boot - int in property file getting read as String?

1.6k views Asked by At

In my application.properties file, I have a line that says

variablename=1000

I then read it in a class with

 @Value("${variablename}")
 private int variablename;

Or with

@Configuration
@ConfigurationProperties
public class ClassName

This gets me an error, telling me that I can't convert from String to int, except I'm not converting to int as far as I'm aware.

Error is:

Failed to bind properties under 'variablename' to int:

Property:variablename Value: 1000 Origin: class path resource [application.properties]:21:8 Reason: failed to convert java.lang.String to int

0

There are 0 answers