Want to improve as a dev?

I send a short email every workday about Spring topics, API development and improving as a dev.

I understand and agree to the privacy policy

Basic properties handling - Part 2

15.03.2018 by Jens in Spring Boot | Newsletter

Properties in Spring are not limited to Strings. Sure, they are in the property file, but not necessarily as a field in our class. Whatever type we use, Spring will try to convert the string value from our input to the correct type.

For example with a boolean:

private boolean myProp;

We can set the value now like:




It doesn’t matter what type we use as long as Spring has a converter for it. It covers the most common cases. If not, we can plug in our own, but honestly, I never had the need for that.

comments powered by Disqus