SpringBoot创建DataSource时遇到的错误:NosupportedDataSourcetypefound

在对Spring Boot进行DataSource配置的时候遇到一个错误

成都创新互联公司2013年开创至今,是专业互联网技术服务公司,拥有项目做网站、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元新华做网站,已为上家服务,为新华各地企业和个人服务,联系电话:18980820575

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'testDataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    ... 93 common frames omitted
Caused by: java.lang.IllegalStateException: No supported DataSource type found
    at org.springframework.boot.jdbc.DataSourceBuilder.getType(DataSourceBuilder.java:146) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:74) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at com.kai.demo.DataSourceConfig.testDataSource(DataSourceConfig.java:37) ~[classes/:na]
    at com.kai.demo.DataSourceConfig$$EnhancerBySpringCGLIB$$e66334f9.CGLIB$testDataSource$3() ~[classes/:na]
    at com.kai.demo.DataSourceConfig$$EnhancerBySpringCGLIB$$e66334f9$$FastClassBySpringCGLIB$$99581351.invoke() ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at com.kai.demo.DataSourceConfig$$EnhancerBySpringCGLIB$$e66334f9.testDataSource() ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    ... 94 common frames omitted

原因是在使用DataSourceBuilder时需要在classpath里指定以下三个中的任意一个:

1.       COMMONS-DBCP

2.       TOMCAT-JDBC

3.       HIKARICP


于是在pom.xml添加了HiKariCP的依赖

		
			com.zaxxer
			HikariCP
			3.2.0
		

错误就没有了


参考地址: https://stackoverflow.com/questions/44635962/error-when-create-datasource


网站题目:SpringBoot创建DataSource时遇到的错误:NosupportedDataSourcetypefound
网站网址:http://bzwzjz.com/article/gcegie.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 攀枝花网站设计 成都网站建设 专业网站建设 成都网站建设公司 成都企业网站制作 手机网站建设 成都网站设计 上市集团网站建设 企业网站建设 成都网站制作 网站设计 成都网站建设 网站建设公司 重庆企业网站建设 成都模版网站建设 移动手机网站制作 成都网站建设公司 网站制作 专业网站设计 网站设计制作 响应式网站设计 成都网站制作