如何在不启动 HikariPool 关闭的情况下使用 Hikari 数据源运行 Spring Boot 应用程序
Posted
技术标签:
【中文标题】如何在不启动 HikariPool 关闭的情况下使用 Hikari 数据源运行 Spring Boot 应用程序【英文标题】:How to run springboot app with Hikari datasource without HikariPool shutdown initiated 【发布时间】:2021-12-21 09:10:26 【问题描述】:我有一个带有 maven 的 Spring Boot 应用程序,并使用 Hikari 数据源连接 mysql 数据库。但是当我运行 spring boot 应用程序时,启动的 HikariPool 关闭发生如下:
C:\Users\Admin\.jdks\corretto-11.0.12\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.1.2\lib\idea_rt.jar=58795:C:\Program Files\JetBrains\IntelliJ IDEA 2021.1.2\bin" -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath C:\Users\Admin\Desktop\PiratedMovieWeb\target\classes;C:\Users\Admin\Desktop\PiratedMovieWeb\lib\javax.jms.jar;C:\Users\Admin\Desktop\PiratedMovieWeb\lib\javax.servlet.jsp.jstl.jar;C:\Users\Admin\Desktop\PiratedMovieWeb\lib\javax.resource.jar;C:\Users\Admin\Desktop\PiratedMovieWeb\lib\javax.servlet.jar;C:\Users\Admin\Desktop\PiratedMovieWeb\lib\javax.ejb.jar;C:\Users\Admin\Desktop\PiratedMovieWeb\lib\javax.servlet.jsp.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-oauth2-client\2.5.5\spring-boot-starter-oauth2-client-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter\2.5.5\spring-boot-starter-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.5.5\spring-boot-starter-logging-2.5.5.jar;C:\Users\Admin\.m2\repository\ch\qos\logback\logback-classic\1.2.6\logback-classic-1.2.6.jar;C:\Users\Admin\.m2\repository\ch\qos\logback\logback-core\1.2.6\logback-core-1.2.6.jar;C:\Users\Admin\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.14.1\log4j-to-slf4j-2.14.1.jar;C:\Users\Admin\.m2\repository\org\apache\logging\log4j\log4j-api\2.14.1\log4j-api-2.14.1.jar;C:\Users\Admin\.m2\repository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;C:\Users\Admin\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\Admin\.m2\repository\org\yaml\snakeyaml\1.28\snakeyaml-1.28.jar;C:\Users\Admin\.m2\repository\com\sun\mail\jakarta.mail\1.6.7\jakarta.mail-1.6.7.jar;C:\Users\Admin\.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-config\5.5.2\spring-security-config-5.5.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-aop\5.3.10\spring-aop-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-context\5.3.10\spring-context-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-core\5.5.2\spring-security-core-5.5.2.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-crypto\5.5.2\spring-security-crypto-5.5.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-expression\5.3.10\spring-expression-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-oauth2-client\5.5.2\spring-security-oauth2-client-5.5.2.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-oauth2-core\5.5.2\spring-security-oauth2-core-5.5.2.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-web\5.5.2\spring-security-web-5.5.2.jar;C:\Users\Admin\.m2\repository\com\nimbusds\oauth2-oidc-sdk\9.9.1\oauth2-oidc-sdk-9.9.1.jar;C:\Users\Admin\.m2\repository\com\github\stephenc\jcip\jcip-annotations\1.0-1\jcip-annotations-1.0-1.jar;C:\Users\Admin\.m2\repository\com\nimbusds\content-type\2.1\content-type-2.1.jar;C:\Users\Admin\.m2\repository\com\nimbusds\lang-tag\1.5\lang-tag-1.5.jar;C:\Users\Admin\.m2\repository\org\springframework\security\spring-security-oauth2-jose\5.5.2\spring-security-oauth2-jose-5.5.2.jar;C:\Users\Admin\.m2\repository\com\nimbusds\nimbus-jose-jwt\9.10.1\nimbus-jose-jwt-9.10.1.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-devtools\2.5.5\spring-boot-devtools-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot\2.5.5\spring-boot-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.5.5\spring-boot-autoconfigure-2.5.5.jar;C:\Users\Admin\.m2\repository\org\projectlombok\lombok\1.18.20\lombok-1.18.20.jar;C:\Users\Admin\.m2\repository\net\minidev\json-smart\2.4.7\json-smart-2.4.7.jar;C:\Users\Admin\.m2\repository\net\minidev\accessors-smart\2.4.7\accessors-smart-2.4.7.jar;C:\Users\Admin\.m2\repository\org\ow2\asm\asm\9.1\asm-9.1.jar;C:\Users\Admin\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\Users\Admin\.m2\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\Users\Admin\.m2\repository\net\bytebuddy\byte-buddy\1.10.22\byte-buddy-1.10.22.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-core\5.3.10\spring-core-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-jcl\5.3.10\spring-jcl-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.5.6\spring-boot-starter-data-jpa-2.5.6.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.5.5\spring-boot-starter-aop-2.5.5.jar;C:\Users\Admin\.m2\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.5.5\spring-boot-starter-jdbc-2.5.5.jar;C:\Users\Admin\.m2\repository\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;C:\Users\Admin\.m2\repository\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;C:\Users\Admin\.m2\repository\org\hibernate\hibernate-core\5.4.32.Final\hibernate-core-5.4.32.Final.jar;C:\Users\Admin\.m2\repository\org\jboss\logging\jboss-logging\3.4.2.Final\jboss-logging-3.4.2.Final.jar;C:\Users\Admin\.m2\repository\org\javassist\javassist\3.27.0-GA\javassist-3.27.0-GA.jar;C:\Users\Admin\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\Admin\.m2\repository\org\jboss\jandex\2.2.3.Final\jandex-2.2.3.Final.jar;C:\Users\Admin\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\Admin\.m2\repository\org\dom4j\dom4j\2.1.3\dom4j-2.1.3.jar;C:\Users\Admin\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.1.2.Final\hibernate-commons-annotations-5.1.2.Final.jar;C:\Users\Admin\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.5\jaxb-runtime-2.3.5.jar;C:\Users\Admin\.m2\repository\org\glassfish\jaxb\txw2\2.3.5\txw2-2.3.5.jar;C:\Users\Admin\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.12\istack-commons-runtime-3.0.12.jar;C:\Users\Admin\.m2\repository\org\springframework\data\spring-data-jpa\2.5.5\spring-data-jpa-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\data\spring-data-commons\2.5.5\spring-data-commons-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-orm\5.3.10\spring-orm-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-aspects\5.3.10\spring-aspects-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.5.5\spring-boot-starter-web-2.5.5.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.5.5\spring-boot-starter-json-2.5.5.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.12.5\jackson-datatype-jdk8-2.12.5.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.12.5\jackson-datatype-jsr310-2.12.5.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.12.5\jackson-module-parameter-names-2.12.5.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-web\5.3.10\spring-web-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-webmvc\5.3.10\spring-webmvc-5.3.10.jar;C:\Users\Admin\.m2\repository\javax\ws\rs\javax.ws.rs-api\2.1.1\javax.ws.rs-api-2.1.1.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.12.5\jackson-annotations-2.12.5.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.12.5\jackson-core-2.12.5.jar;C:\Users\Admin\.m2\repository\io\jsonwebtoken\jjwt\0.9.1\jjwt-0.9.1.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-jdbc\5.3.9\spring-jdbc-5.3.9.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-beans\5.3.10\spring-beans-5.3.10.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-tx\5.3.10\spring-tx-5.3.10.jar;C:\Users\Admin\.m2\repository\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;C:\Users\Admin\.m2\repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;C:\Users\Admin\.m2\repository\mysql\mysql-connector-java\8.0.16\mysql-connector-java-8.0.16.jar;C:\Users\Admin\.m2\repository\com\google\code\gson\gson\2.8.2\gson-2.8.2.jar;C:\Users\Admin\.m2\repository\io\swagger\swagger-annotations\1.6.2\swagger-annotations-1.6.2.jar com.example.piratedmovieweb.PiratedMovieWebApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.5)
2021-11-08 21:09:15.272 INFO 11796 --- [ restartedMain] c.e.p.PiratedMovieWebApplication : Starting PiratedMovieWebApplication using Java 11.0.12 on DESKTOP-OFQLT9I with PID 11796 (C:\Users\Admin\Desktop\PiratedMovieWeb\target\classes started by Admin in C:\Users\Admin\Desktop\PiratedMovieWeb)
2021-11-08 21:09:15.273 INFO 11796 --- [ restartedMain] c.e.p.PiratedMovieWebApplication : No active profile set, falling back to default profiles: default
2021-11-08 21:09:15.307 INFO 11796 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-11-08 21:09:15.307 INFO 11796 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-11-08 21:09:15.717 INFO 11796 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-11-08 21:09:15.732 INFO 11796 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 9 ms. Found 0 JPA repository interfaces.
2021-11-08 21:09:15.910 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : Driver class com.mysql.cj.jdbc.Driver found in Thread context class loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@13c357f2
2021-11-08 21:09:15.977 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : HikariPool-1 - configuration:
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : allowPoolSuspension.............false
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : autoCommit......................true
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : catalog.........................none
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : connectionInitSql...............none
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : connectionTestQuery.............none
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : connectionTimeout...............30000
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSource......................none
2021-11-08 21:09:15.979 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSourceClassName.............none
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSourceJNDI..................none
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : dataSourceProperties............password=<masked>
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : driverClassName................."com.mysql.cj.jdbc.Driver"
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : exceptionOverrideClassName......none
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : healthCheckProperties...........
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : healthCheckRegistry.............none
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : idleTimeout.....................600000
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : initializationFailTimeout.......1
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : isolateInternalQueries..........false
2021-11-08 21:09:15.980 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : jdbcUrl.........................jdbc:mysql://localhost:3306/piratedmovie?allowPublicKeyRetrieval=true&useSSL=false
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : leakDetectionThreshold..........0
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : maxLifetime.....................1800000
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : maximumPoolSize.................5
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : metricRegistry..................none
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : metricsTrackerFactory...........none
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : minimumIdle.....................5
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : password........................<masked>
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : poolName........................"HikariPool-1"
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : readOnly........................false
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : registerMbeans..................false
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : scheduledExecutor...............none
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : schema..........................none
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : threadFactory...................internal
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : transactionIsolation............default
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : username........................"root"
2021-11-08 21:09:15.981 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.HikariConfig : validationTimeout...............5000
2021-11-08 21:09:15.981 INFO 11796 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-11-08 21:09:16.078 DEBUG 11796 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@405e1d52
2021-11-08 21:09:16.080 INFO 11796 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-11-08 21:09:16.141 INFO 11796 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-11-08 21:09:16.180 INFO 11796 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-11-08 21:09:16.182 DEBUG 11796 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Pool stats (total=1, active=0, idle=1, waiting=0)
2021-11-08 21:09:16.189 DEBUG 11796 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@56b5de06
2021-11-08 21:09:16.193 DEBUG 11796 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@1788d43d
2021-11-08 21:09:16.197 DEBUG 11796 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@26d5246a
2021-11-08 21:09:16.202 DEBUG 11796 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@77a72b72
2021-11-08 21:09:16.202 DEBUG 11796 --- [onnection adder] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - After adding stats (total=5, active=0, idle=5, waiting=0)
2021-11-08 21:09:16.284 INFO 11796 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations 5.1.2.Final
2021-11-08 21:09:16.362 INFO 11796 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2021-11-08 21:09:16.746 INFO 11796 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-11-08 21:09:16.752 INFO 11796 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-11-08 21:09:16.872 INFO 11796 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-11-08 21:09:16.890 INFO 11796 --- [ restartedMain] c.e.p.PiratedMovieWebApplication : Started PiratedMovieWebApplication in 1.93 seconds (JVM running for 2.75)
2021-11-08 21:09:16.898 INFO 11796 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-11-08 21:09:16.901 INFO 11796 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-11-08 21:09:16.901 DEBUG 11796 --- [ionShutdownHook] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Before shutdown stats (total=5, active=0, idle=5, waiting=0)
2021-11-08 21:09:16.902 DEBUG 11796 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@405e1d52: (connection evicted)
2021-11-08 21:09:16.904 DEBUG 11796 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@56b5de06: (connection evicted)
2021-11-08 21:09:16.904 DEBUG 11796 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@1788d43d: (connection evicted)
2021-11-08 21:09:16.904 DEBUG 11796 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@26d5246a: (connection evicted)
2021-11-08 21:09:16.905 DEBUG 11796 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Closing connection com.mysql.cj.jdbc.ConnectionImpl@77a72b72: (connection evicted)
2021-11-08 21:09:16.905 DEBUG 11796 --- [ionShutdownHook] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
2021-11-08 21:09:16.905 INFO 11796 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
我配置属性文件如下,可以正常使用单元测试获取数据查询:
# =============Database config==================
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/piratedmovie?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456_
spring.datasource.hikari.maximum-pool-size=5
# ==============JPA / HIBERNATE=================
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.generate-ddl=true
spring.main.web-application-type=none
logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
logging.level.com.zaxxer.hikari=TRACE
我还根据许多人的建议添加了 spring-boot-starter-web、HikariCP、spring-boot-starter-data-jpa,但无法解决此问题。
任何人都可以为我提供解决方案来解决此问题。 谢谢
【问题讨论】:
【参考方案1】:当您指定 spring.main.web-application-type=none
时,您是在告诉 Boot 不要启动嵌入式 servlet 容器。因此,您的应用程序初始化并启动,然后关闭。注释掉这个属性,它应该开始暴露任何其他问题。
【讨论】:
谢谢,但我之前尝试删除此行,但之后发生其他问题: org.springframework.context.ApplicationContextException: Unable to start web server;嵌套异常是 org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean。 你能展示你的“主要”课程吗?您的主类是否使用 @SpringBootApplication 注释?以上是关于如何在不启动 HikariPool 关闭的情况下使用 Hikari 数据源运行 Spring Boot 应用程序的主要内容,如果未能解决你的问题,请参考以下文章
如何在不先启动 IE 的情况下使我的 WinCE 应用程序中的网络工作?
有没有办法在不重新启动应用程序的情况下使 NSBundle 本地化缓存失效? [iOS]