大家好,我是Spring Boot的新手。当我第一次尝试获取数据时,API需要花费很长时间进行响应。一旦返回数据,接下来的呼叫将立即给出响应。但是,如果在接下来的6分钟内未调用该API,则下次调用将再次花费更长的时间。对不起,语法不好。
spring boot版本:带有jpa的2.0.3释放
数据库:Mysql
配置
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://*************
driver-class-name: com.mysql.jdbc.Driver
username: ********
password: ********
hikari:
connection-timeout: 30000
idle-timeout: 600000
maxLifetime: 1800000
jpa:
hibernate:
ddl-auto: none
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
show-sql: true
properties:
hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
Servlet在第一个请求到来之前不会启动。下面的application.properties配置使Tomcat启动时加载servlet。因此,第一个请求将以较少的响应时间获得良好的性能。spring.webservices.servlet.load-on-startup = 1