![](/img/trans.png)
[英]Environment Variables in spring-boot application.properties error
[英]environment variables in Spring-Boot in email data in application.properties
您可以在 applitacation.properties 文件中的電子郵件數據中添加 Spring-Boot 中的環境變量嗎? 就我而言,我使用 Linux 並在 /etc/environment 中配置環境變量
它與
spring.datasource.url=${SPRING_DATASOURCE_URL}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
但它不適用於
spring.mail.host=${SPRING_MAIL_HOSTNAME}
spring.mail.port=${SPRING_MAIL_PORT}
spring.mail.username=${SPRING_MAIL_USERNAME}
spring.mail.password=${SPRING_MAIL_PASSWORD}
這有什么區別?
它應該可以工作,但您沒有指定什么不工作。 為了使這些屬性有用,您必須連接正確的 Spring Boot 插件並在您的代碼中使用它:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.7.0</version>
</dependency>
// wire it in your bean
@Autowired
private JavaMailSender emailSender;
// reference the emailSender and send emails ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.