Maven filters stopped working/How to handle ENV properties in Maven Builds

I just finished implementing environment specific profiles in my maven project, which works great. After some time it stopped working. WTF.

The reason for that is because I made the project a Spring Boot project by adding the spring-boot-starter-parent to my POM file.

Normally you access filter variables using the ${variable} syntax in .properties files. But, as it turns out (see box):

If you are using Spring Boot, you have to use @variable@ instead! Source {: .notice–danger}

Here is the documentation page.

Took me a few hours to figure out. As soon as I changed the references in application.properties, all my file logging and stuff started working again.

How to handle environment specific properties during maven build

Filters are a really bad way of managing environment specific configuraton. Programmers have a tendency, when, given a hammer, to use that hammer for everything, including china vase repairs. {: .notice–danger}

A colleague at work pointed this out to me.

He suggested the better alternative is to create config modules in maven. These contain all the property files for a specific environment. Then use maven profiles to reference only the desired set of property files at build time using a -Pstaging flag on the mvn package command.

Related posts

How to Optimize Docker Builds with Nexus OSS for Apt, Maven, Docker and NPM Dependencies

Docker could not find an available, non-overlapping IP address pool

Github Workflow for Electron React Boilerplate with Auto Updates

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More