Nikita Saboo
Nikita Saboo

Reputation: 73

@value annotation returns me a wrong value

When accessing a property with value 7777 @value annotation returns me 20080

code used:

    @Value(value = "${proxy.port:0}")
    private Integer proxyPort;

is it changing the number base or something ?

Additional information: On eclipse the value is 7777 , when I deploy this on a server the value changes . On server I run it in a jar .

Upvotes: 0

Views: 1066

Answers (3)

Varesh
Varesh

Reputation: 1758

I think the issue here is that on server there might be an environment variable that could have different value. Spring treats those at highest preference over values defined in property. Check on your server, if there is a environment variable defined with the same name.

Upvotes: 2

Nate T
Nate T

Reputation: 785

Try setting properties from inside application.yml as opposed to application.properties

Upvotes: 0

Deepak Kharpuriya
Deepak Kharpuriya

Reputation: 175

Can you please use

@Value("${proxy.port}")

or with default

@Value("${proxy.port:0}")

As https://stackoverflow.com/users/9466638/eugene-kortov mentioned, please also check profile specific properties files.

Upvotes: 0

Related Questions