无活动状态后,Spring罩关闭连接

n7taea2i  于 2022-10-05  发布在  Maven
关注(0)|答案(1)|浏览(168)

我有一个项目在 Spring 启动运行在开发服务器上,这个项目连接到一个Oracle数据库。

我尝试使用Hiraki和oracleucp,但过了一段时间,连接关闭,API服务器关闭。

该项目在.jar文件中编译

错误:

o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'

aplication.properties

spring.datasource.url=jdbc:oracle:thin:@ip:port:name
spring.datasource.username=********
spring.datasource.password=********

spring.jpa.hibernate.ddl-auto=none

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.type=oracle.ucp.jdbc.PoolDataSource

spring.datasource.oracleucp.connection-factory-class-name=oracle.jdbc.pool.OracleDataSource
spring.datasource.oracleucp.connection-pool-name=connectionPoolName1
spring.datasource.oracleucp.initial-pool-size=15
spring.datasource.oracleucp.min-pool-size=10
spring.datasource.oracleucp.max-pool-size=30
spring.datasource.oracleucp.s-q-l-for-validate-connection=SELECT 69 FROM DUAL
spring.datasource.oracleucp.validate-connection-on-borrow=true
spring.datasource.oracleucp.connection-validation-timeout=500
spring.datasource.oracleucp.timeout-check-interval=500

# Cors

spring.mvc.dispatch-options-request=true

# server

server.port=8083
server.port.http=8081

# SSL

server.ssl.key-store-type=JKS
server.ssl.key-store=../keystore/keystore.jks
server.ssl.key-store-password=changeit
server.ssl.key-alias=ws.upb.edu.co
server.ssl.enabled=true

## MULTIPART (MultipartProperties)

# Enable multipart uploads

spring.servlet.multipart.enabled=true

# Threshold after which files are written to disk.

spring.servlet.multipart.file-size-threshold=2KB

# Max file size.

spring.servlet.multipart.max-file-size=200MB

# Max Request Size

spring.servlet.multipart.max-request-size=215MB

# logging

logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug

# logging.level.org.hibernate.type.descriptor.sql=trace

logging.level.=error

spring.mail.host= host 
spring.mail.port= port
spring.mail.username= mail
spring.mail.password= mail.password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

谢谢

h79rfbju

h79rfbju1#

我建议查看您的pom.xml。我认为您添加了一些与其他依赖项冲突的内容。例如,如果pom.xml同时包含spring-boot-starter-webspring-boot-starter-tomcat依赖项。

如下所示:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
</dependency>

-- remove this starter tomcat dependency
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

spring-boot-starter-web有一个默认的嵌入式Tomcat。

移除spring-boot-starter-tomcat后,您必须运行mvn clean install

相关问题