gpt4 book ai didi

java - Spring boot REST 服务在一段时间后停止

转载 作者:太空宇宙 更新时间:2023-11-04 12:48:54 35 4
gpt4 key购买 nike

触发 Spring Boot REST 服务后,该服务可以正常运行几个小时,所有请求都可以正常工作,没有任何问题。发生的情况是,一段时间后,它随机停止。在查看日志时,除了应用程序已被破坏的信息之外,我没有发现任何错误。

一段时间后记录

2016-03-09 17:07:33.488  INFO 28359 --- [Thread-12] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5df2d54c: startup date [Wed Mar 09 10:45:18 UTC 2016]; root of context hierarchy
2016-03-09 17:07:33.490 INFO 28359 --- [Thread-12] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2016-03-09 17:07:33.495 INFO 28359 --- [Thread-12] o.eclipse.jetty.server.ServerConnector : Stopped ServerConnector@585ebc93{SSL-HTTP/1.1}{0.0.0.0:8443}
2016-03-09 17:07:33.496 INFO 28359 --- [Thread-12] application : Destroying Spring FrameworkServlet 'dispatcherServlet'
2016-03-09 17:07:33.496 INFO 28359 --- [Thread-12] o.e.jetty.server.handler.ContextHandler : Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@3d3969ea{/,file:/tmp/jetty-docbase.5267015092605924805.8443/,UNAVAILABLE}

Maven 依赖项

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

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

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>

<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.drill.exec</groupId>
<artifactId>drill-jdbc</artifactId>
<exclusions>
<exclusion>
<artifactId>hadoop-common</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-client</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<!-- used to update stopwatch -->
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.drill</groupId>
<artifactId>drill-common</artifactId>
<exclusions>
<exclusion>
<artifactId>hadoop-common</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<artifactId>hadoop-client</artifactId>
<groupId>org.apache.hadoop</groupId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>


</dependencies>

对于为什么 Spring Boot REST API 可能会停止有什么想法吗?我的 Maven 依赖项是根据演示 - 并且它已成功运行 - 这就是为什么服务在随机时间后停止,这是没有意义的。

我用于 Spring Boot 的日志记录设置是

logging.level.org.springframework.web = DEBUG
logging.level.org.hibernate = ERROR
logging.file = /home/REST/Logging.log

最佳答案

根本原因是我与 MySQL 的连接过时

spring.xxx.datasource.testOnBorrow=true
spring.xxx.datasource.validationQuery=SELECT 1

更多详细信息请点击 https://docs.spring.io/spring-ldap/docs/1.3.2.RELEASE/reference/html/pooling.html

关于java - Spring boot REST 服务在一段时间后停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36035828/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com