将项目部署到阿里云服务器的几个坑
配置SSL证书
由于 Spring Boot 内置了 Tomcat , 故将 Tomcat 服务器的配置写在项目的配置文件 application.yml 中。
在阿里云里可以申请到赛门铁克免费型DV SSL证书, 审核通过后下载的证书有两个文件, 分别是 ***.pfx 和 ***.txt 。
txt文件里面存储的是证书的密码, pfx文件就是证书。
1 | server: |
使用阿里云企业邮箱发送邮件
阿里云邮箱服务器地址列表:
| 协议 | 服务器地址 | 服务器端口号(常规) | 服务器端口号(加密) |
|---|---|---|---|
| POP3 | pop.qiye.aliyun.com | 110 | 995 |
| IMAP | imap.qiye.aliyun.com | 143 | 993 |
| SMTP | smtp.qiye.aliyun.com | 25 | 465 |
阿里云邮箱服务器列表(旧地址):
| 协议 | 服务器地址 | 服务器端口号(常规) | 服务器端口号(加密) |
|---|---|---|---|
| POP3 | pop3.mxhichina.com | 110 | 995 |
| IMAP | imap.mxhichina.com | 143 | 993 |
| SMTP | smtp.mxhichina.com | 25 | 465 |
阿里云服务器ECS封禁了25端口, 且阿里云企业邮箱 SMTP 不支持 Starttls
Tomcat 在启动的时候耗时
如果在打印的日志中看到 Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [x,xxx] milliseconds. 这个警告, 则可以使用下面的方法
在 JDK 中找到 java.security 文件, 将 securerandom.source=file:/dev/urandom 修改为 securerandom.source=file:/dev/./urandom