公司安排任务,排查SpringCloud项目接口访问慢。
登录接口很慢,需要30秒。再次登录就只需要几毫秒
登录成功后,随便一个查询接口也需要15秒。再次访问也只需要几毫秒
退出登录接口,只需要几毫秒。其他不需要操作数据库的接口也很快
连接mysql问题,检查项目的yml配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:/${ip}:${端口号}/xxxxxxxxxxxxxxxxxxx
username: ${账号}
password: ${密码}
ip端口都是从公共配置里面读取的,
改为具体的连接地址,端口号
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:/localhost:3306/xxxxxxxxxxxxxxxxxxxxx
username: root
password: 123456
测试登录接口,2秒
问题解决