After Maven has set SpringBoot Profile, the @ Value ("${xx}") value cannot be accessed. How to solve this problem?

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder "alipay.app_id" in value "${alipay.app_id}"

Project structure

clipboard.png

clipboard.png

I wrote it in application.properties before it was not configured. I can get the value by using @ Value ("${xx}"), but now I have configured a different profile. After I put the value in application-*.properties, I failed to get it.


have you chosen which profile to use?


has been solved. The reason for the problem is that the constructor executes @ Value first, so you can't get the value in @ Value

.
Menu