Problem Description:
Use springboot to connect to the database, an error is reported when starting: testWhileIdle is true, validationQuery not set. But it does not affect the use of the system, and all access to the database is normal.
The application.properties data source configuration is as follows:
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.initial-size=1
spring.datasource.maximum-pool-size=10
spring.datasource.connection-timeout=5000
Solution:
springboot1.4 cancel spring.datasource.type
In the new version, the validationQuery is not automatically injected, so you need to manually declare the datasource bean. As for how to write, you can read the above article.
It is mainly to manually inject DruidDataSource, declare a configuration class, inject all values of the data source into it, and return to DruidDataSource.
Restart, the system does not report an error!
Finally, I checked the DruidDataSource source code,
public static final String DEFAULT_VALIDATION_QUERY = null;
Sure enough, the DruidDataSource default testWhileIdle=true, and the validationQuery is set to empty.
Read More:
- Error reported when springboot connects to redis nested exception is redis.clients.jedis . exceptions.JedisConnectionException
- ORA-12505 error when java connects to oracle database
- [Solved] Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
- ES Error: Alternatively, set fielddata=true on [How to Solve]
- Resolve InsecurePlatformWarning: A true SSLContext object is not available.
- [Solved] Failed assertion: line 3180 pos 12: ‘debugNeedsPaint‘: is not true
- Error: env [NODE_ENV] is not set (How to Solve)
- [Solved] Springboot project Create to start Error: APPLICATION FAILED TO START
- Django Error: ‘set‘ object is not reversible [How to Solve]
- [Solved] There are test failures. Please refer to D:\Java_study\springboot\springboot-sugon-3\target\surefire-reports for the individual test results.
- [Solved] Springboot Reflection calls ServiceImpl Error: java.lang.NullPointerException, mapper is null
- [Solved] Cmake compile opencv open-source project Error: but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be…
- [Solved] Android Room: Database Common Error ‘missing database’
- [Solved] SpringBoot Error: HttpMediaTypeNotSupportedException: Content type ‘application/json‘ not supported
- SpringBoot startup error Failed to determine a suitable driver class
- SVN ERROR (E200033): database is locked [How to Solve]
- RabbitMQ Configuration File Error: publisher-confirms=true [Solved]
- [Solved] MindSpore Error: `half_pixel_centers`=True only support in Ascend
- When using postman assertion, the global variables set in the tests of the pit will take effect only after the interface is executed