java - Spring boot + Spring mail:标准{PORT}问题
问题描述
您好,在我将 spring 邮件添加到我的应用程序后,我遇到了一个问题。这些是问题所在的 app.propreties。
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.auth=true
server.port=${PORT}
这就是我在 EmailConfig 类中绑定它的方式
@Value("${spring.mail.port}")
private int port;
这也是我正在使用的邮件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
每次我启动应用程序时,我都会收到此错误:
Description:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: ${PORT}
Origin: class path resource [application.properties]:20:13
Reason: failed to convert java.lang.String to java.lang.Integer
Action:
Update your application's configuration
出于某种原因,我似乎无法在基本的 8080 端口上发出请求。因此,我已将 server.port 修改为此server.port=${PORT:9191}
并且它可以工作,但是由于某种原因,我的某些页面出现了一些请求问题。问题是,我在另一个应用程序上具有相同的配置,它无需我将端口修改为不同的数字即可工作。为什么会发生这种情况?我想留在标准港口。
任何帮助将不胜感激 !
解决方案
app.properties
server.port
在您尝试访问的代码中拥有属性,该代码${spring.mail.port}
为空。
推荐阅读
- python-3.x - 使用服务主体从 ADLS gen2 读取镶木地板文件
- python - 使用 Python xlwings 激活(切换到)另一本打开的 excel 书
- c++ - 如何在 C++ 中调用模板运算符 []?
- arrays - 一个人在C的终端中输入值后如何将值保存到文件中?
- javascript - 使用节点 js 在递归中调用异步函数
- python - django.core.exceptions.AppRegistryNotReady:应用程序尚未加载。在 Django 3.1 中
- objective-c - 如何更改声音的非实时音高/采样率?
- php - PHP 范围解析运算符产生未定义的类常量
- ios - 在根据条件显示的两个视图上使用相同的 `navigationBarTitle` 和 `navigationBarItems`
- python - Xgboost 未与校准分类器一起运行