Answer the question
In order to leave comments, you need to log in
Why does Spring ignore configuration properties of profile files?
Hello!
I've asked this question before, but unfortunately I haven't found an answer yet.
Old question - How to understand Spring profiles?
In short:
- Built a project from https://start.spring.io/ and imported it into intellij idea.
- Created 2 additional properties file application-production.properties & application-development.properties. Both files are in resources at the level with the application.properties file
- Added to the application.properties file: spring.profiles.active=development
- Added to the application-development.properties file:
server.port=7777
spring.mail.host=smtp.yandex.ru
[email protected]
spring.mail.password=12345
spring.mail.port=465
spring.mail.protocol=smtps
mail.debug=true
@Value("${spring.mail.host}")
private String host;
Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.mail.host' in value "${spring.mail.host}"
Answer the question
In order to leave comments, you need to log in
Try using YAML and put all profiles in one file, like this:
#application.yml
spring.profiles.active: development
---
spring:
profiles: development
server.port: 7777
spring.mail.host: smtp.yandex.ru
spring.mail.username: [email protected]
spring.mail.password: 12345
spring.mail.port: 465
spring.mail.protocol: smtps
mail.debug: true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question