SQL Server Connection在空闲一段时间后即被关闭

时间:2018-02-24 13:07:32

标签: sql-server azure spring-boot

我已经在Azure中部署了我的spring启动应用程序,并且它正在与Azure中运行的SQL Server数据库进行通信。我能够点击其余端点并获取JSON数据。但是当应用程序空闲一段时间后,我正试图点击相同的休息端点时,我收到以下错误。

错误

 org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction.

com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.] with root cause. 

这是我的 application.yml

spring:
  profiles:
    active:sql_server
  application:
    name: facilitiesmanagement
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: none
liquibase:
  change-log: classpath:db/changelog/db.changelog-master.xml

spring:
  profiles: sql_server
  datasource:
    url: jdbc:sqlserver://testserver.database.windows.net;databaseName=test
    username: hello
    password: passw@ord
    initialize: true
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    dbcp2:
      initial-size: 10
      max-total: 25
      pool-prepared-statements: true
    jpa:
      database-platform: org.hibernate.dialect.SQLServer2012Dialect
      database: sql_server

有人可以帮我解决如何在不关闭的情况下使连接一直运行。我是否需要添加任何其他属性才能实现?

我正在使用6.1.0.jre8版本和基本层次计划

0 个答案:

没有答案
相关问题