1
votes

I am using the milestone branch of Spring Boot (2.0.0.M7) with Gradle. I have some set of values in application.properties

app.name=MyApp
app.description=Hello from MyApp
app.version=1.0

In my application-DEV.properties I have

app.version=1.0-DEV

In my SpringBootApplication i am injecting the value as

@Value("${app.name}")
private String name;

@Value("${app.version}")
private String version;

I put application-default.properties in the current dir which has following data

app.version=1.0-DEVX
spring.profiles.active=DEV

When I run my SpringBootApplication from IDE, it works fine. But when I build jar and run it as java -jar MyApplication.jar it gives an error

Could not resolve placeholder 'app.name' in value "${app.name}"

It works fine if i replicate all the values into application-default.properties or in application-DEV.properties. It also works fine if i use Spring Boot 1.5.9-RELEASE or older.

I dont see any documentation that the profile overrides have changed. Maybe its a bug?

1
Can you explode your jar and make sure your properties file is making it in? - benashby
Yes its in there in application jar!/BOOT-INF/classes - Mohan

1 Answers

0
votes

There was an application.properties that was packaged in another jar which was causing this issue. After removing the application.properties from that jar, it works as intended.