Spring Boot - Using ${} placeholders in Property Files

[Last Updated: Jul 19, 2017]

In the last example, we saw maven resource filtering in boot application. Spring also provides it's own variable substitution in property files. We just need to use ${someProp} in property file and start the application having 'someProp' in system properties or as main class (or jar) argument '--someProp=theValue'.

This feature allows us to use 'short' command line arguments.



app.title=Boot ${app} @project.artifactId@

Note that, in above example, we are also using maven variables @..@ (last tutorial).

public class ExampleMain {
    MyBean myBean() {
        return new MyBean();

    public static void main(String[] args) throws InterruptedException {
        SpringApplication bootApp = new SpringApplication(ExampleMain.class);
        ConfigurableApplicationContext context =;
        MyBean myBean = context.getBean(MyBean.class);

    private static class MyBean {

        private String appTitle;

        public void doSomething() {
            System.out.printf("App title : %s%n", appTitle);
mvn spring-boot:run -Dapp=Example


d:\example-projects\spring-boot\place-holders-in-properties>mvn spring-boot:run -Dapp=Example
App title : Boot Example place-holders-in-properties

Example Project

Dependencies and Technologies Used:

  • Spring Boot 1.5.4.RELEASE
    Corresponding Spring Version 4.3.9.RELEASE
  • spring-boot-starter : Core starter, including auto-configuration support, logging and YAML.
  • JDK 1.8
  • Maven 3.3.9

Using Placeholders in Property Files Select All Download
  • place-holders-in-properties
    • src
      • main
        • java
          • com
            • logicbig
              • example
        • resources

    See Also