1

This is the code that I'm using to reading the application.properties file in a gradle project.

@PropertySource("${spring.profiles.active}/application.properties")

My file is located inside resources/local/application.properties

This is how I'm trying to run the application in IntelliJ

enter image description here

This is the error that I end up getting.

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.core.Application]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.profiles.active' in value "${spring.profiles.active}/application.properties"

Can someone help me fix this and read the correct config.

Melissa Stewart
  • 3,483
  • 11
  • 49
  • 88

1 Answers1

2

You're trying to get spring.profiles.active but in Intellij you're setting spring.active.profiles

juanlumn
  • 6,155
  • 2
  • 30
  • 39
  • I fixed this it still doesn't work. I get the following error ```org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.core.Application]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.active.profiles' in value "${spring.active.profiles}/application.properties"``` – Melissa Stewart Sep 20 '17 at 19:35
  • I think you swapped the names, try spring.profiles.active for more info check [this link](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html) – juanlumn Sep 20 '17 at 19:54
  • I've tried all possible combinations. It doesn't work. – Melissa Stewart Sep 20 '17 at 20:08
  • Have you tried setting it in Arguments or Environment variables instead of in VMoptions? – juanlumn Sep 20 '17 at 21:44
  • @MelissaStewart please take a look into [this post](https://stackoverflow.com/questions/39738901/how-do-i-activate-a-spring-boot-profile-when-running-from-intellij) I think it can help you too – juanlumn Sep 21 '17 at 13:17