Я использую spring-boot для создания веб-проекта. Хотя проект работает хорошо, я считаю, что веб-сервер продолжает запускаться и выключаться по журналу, я хочу выяснить, почему?
Я инициировал проект, как сказано в руководствах spring.io: https://github.com/spring-guides/gs-maven/archive/master.zip и я использую mysql-8.0.16-winx64 в качестве базы данных.
Я запускаю веб-сервер Spring-boot следующим образом:
@SpringBootApplication
@ComponentScan({"controller","service"})
@MapperScan("model.mapper")
public class StartWebServer {
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(StartWebServer.class, args);
}
}
конфигурация hikari
spring.datasource.hikari.connectionTimeout=3000
spring.datasource.hikari.maxLifetime=300000
spring.datasource.hikari.maximumPoolSize=50
Все в порядке, за исключением того, что я продолжаю видеть информацию ниже, показывающую, что WebServer перезагружается снова и снова, я не могу понять, почему, интервал запуска и выключения кажется случайным. Веб-страницы доступны постоянно, что означает, что мой проект работает нормально, но я думаю, что сервер не должен запускаться и выключаться несколько раз, так что вы можете помочь мне выяснить, почему это происходит, что-то я пропустил или неправильно настроил? Я упустил некоторые журналы для лучшего отображения.
Обнаружен новый симптом: в моем проекте только один экземпляр mysql, когда я запускаю две JVM, подключенные к одному и тому же серверу mysql, пул отключается и запускается.
[ restartedMain] run.StartWebServer : Starting StartWebServer on admin with PID 2772 ()
[ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
[ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
[ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
[ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
[ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3483 ms
[ restartedMain] com.zaxxer.hikari.HikariConfig : HikariPool-1 - idleTimeout is close to or more than maxLifetime, disabling it.
[ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
[ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
[ restartedMain] run.StartWebServer : Started StartWebServer in 7.298 seconds (JVM running for 8.587)
[nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
[nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
[nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 7 ms
[ Thread-1] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[ Thread-1] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
[ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
[ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
[ restartedMain] run.StartWebServer : Starting StartWebServer on admin with PID 2772 ()
[ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
[ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
[ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
[ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 933 ms
[ restartedMain] com.zaxxer.hikari.HikariConfig : HikariPool-2 - idleTimeout is close to or more than maxLifetime, disabling it.
[ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
[ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
[ restartedMain] run.StartWebServer : Started StartWebServer in 1.883 seconds (JVM running for 19133.015)
[ restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
[ Thread-12] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[ Thread-12] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
[ Thread-12] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated...
[ Thread-12] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed.
[ restartedMain] run.StartWebServer : Starting StartWebServer on admin with PID 2772 ()
[ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
[ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
[ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
[ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
[ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1027 ms
[ restartedMain] com.zaxxer.hikari.HikariConfig : HikariPool-3 - idleTimeout is close to or more than maxLifetime, disabling it.
[ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Starting...
[ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Start completed.
[ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
[ restartedMain] run.StartWebServer : Started StartWebServer in 1.74 seconds (JVM running for 19183.524)
[ restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
[nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
[nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
[nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 5 ms
[nio-8080-exec-2] freemarker.beans : Detected multiple classes with the same name, "model.pojo.DailyPrice". Assuming it was a class-reloading. Clearing class introspection caches to release old data.
[ Thread-16] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[ Thread-16] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
[ Thread-16] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Shutdown initiated...
[ Thread-16] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Shutdown completed.