'Spring boot ignores "ignoreUnresolvablePlaceholders" = true

I'm having a problem with my Spring Boot application ignoring my ignoreUnresolvablePlaceHolders set to true in my config.xml file.

I have these options explicitly set:

<property name="ignoreUnresolvablePlaceholders" value="true" />
<!-- <property name="localOverride" value="false" /> -->
<property name="ignoreResourceNotFound" value="true" />

It works fine in a Junit but when I run my app as a Spring Boot it throws a Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder on startup.

Everything started to fail when I added Spring Profiles like this:

<beans profile="default,dev">

Any help would be very much appreciated...



Solution 1:[1]

By default if SpringBoot is unable to read the properties file then it will throw error. In case you want it to ignore the unresolvable property sources and not throw any error then set attribute ignoreResourceNotFound to true or set attribute ignoreUnresolvablePlaceHolders to true as below.

@Configuration
@PropertySource(name="unknown",                
                value="classpath:${unresolvable}/unknown.properties",
                ignoreResourceNotFound=true)
public class SpringPropertySourceIgnoreUnresolvableErrorExample {
    //....
}

For more information, you can refer below link https://www.javarticles.com/2016/01/spring-propertysources-annotation-example.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Costi Muraru