Want to improve as a dev?

I send a short email every workday about Spring topics, API development and improving as a dev. The current series is about building a Kanban API with Spring.

Properties handling - Placeholders

19.03.2018 by Jens in Spring Boot | Newsletter

We can also use placeholders in properties. A placeholder is a simple reference to another defined property, like a variable.

Let’s see it in action:

my.host=localhost
my.url=http://${my.host}/remote-call.whatever

The placeholder has the same syntax as the expression in the @Value annotation. It’s SpEL after all.

So, the value of my.url will be http://localhost/remote-call.whatever.

However, don’t overdo it. If it gets too complex, it will be hard to maintain - there is no compile time error.


comments powered by Disqus