Spring Boot建立DataSource時遇到的錯誤:No supported DataSource type found
在對Spring Boot進行DataSource配置的時候遇到一個錯誤
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(<generated>) ~[classes/:na] at com.kai.demo.DataSourceConfig$$EnhancerBySpringCGLIB$$e66334f9$$FastClassBySpringCGLIB$$99581351.invoke(<generated>) ~[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(<generated>) ~[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的依賴
<dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <version>3.2.0</version> </dependency>
錯誤就沒有了
參考地址: https://stackoverflow.com/questions/44635962/error-when-create-datasource
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10314474/viewspace-2200344/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Spring Boot + Mybatis + Spring MVC環境配置(三):DataSource配置Spring BootMyBatisMVC
- Idea啟動專案報{dataSource-1} closed錯誤Idea
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource couldAI
- No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1BeanJavaSQLAIAST
- Spring Boot配置是遇到錯誤:jdbcUrl is required with driverClassNameSpring BootJDBCUI
- Spring DataSource>DBCP & C3P0Spring
- 苞米豆的多資料來源 → dynamic-datasource-spring-boot-starter,挺香的!Springboot
- 使用DataSource-Proxy在Spring Boot中記錄SQL語句 - Vlad MihalceaSpring BootSQL
- 出現錯誤 Project ‘org.springframework.boot:spring-boot-starter-parent’ not foundProjectSpringFrameworkboot
- 連線oracle資料庫時,報錯:{dataSource-1} init errorOracle資料庫Error
- Springboot 啟動時不報錯一直卡住,{dataSource-1} initedSpring Boot
- Error creating bean with name ‘dataSource‘ErrorBean
- Spring Boot 2.5.0 釋出:支援Java16、Gradle 7、Datasource初始化機制調整Spring BootJavaGradle
- 啟動tomcat時,日誌裡大量輸出建立資料來源dataSource的日誌Tomcat
- 部署 SAP UI5 應用到 SAP BTP 時遇到的 fiori not found 錯誤訊息UI
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embeddedAI
- Maven建立專案遇到導包錯誤:Maven
- Spring boot/Spring 統一錯誤處理方案的使用Spring Boot
- 使用React Hooks時遇到的錯誤提示ReactHook
- Eclipse 給 Java 應用建立 Run configuration 時找不到 main type 的錯誤訊息EclipseJavaAI
- Grafana的Datasource外掛開發實踐二Grafana
- Grafana的Datasource外掛開發實踐一Grafana
- 寫一個Spark DataSource的隨手筆記Spark筆記
- 七、Spring Boot 錯誤處理原理 & 定製錯誤頁面Spring Boot
- Spring Boot返回靜態錯誤頁面Spring Boot
- Spring Boot配置錯誤:Failed to determine a suitable driver classSpring BootAIUI
- 使用 Spring Boot 提供API錯誤訊息的好方式Spring BootAPI
- KSQLException: The authentication type 10 is not supported.SQLException
- 如何處理用程式碼建立SD Sales order時遇到的錯誤訊息KI 180
- Error creating bean with name ‘dataSource‘: Unsatisfied dependency expressed through fieldErrorBeanExpress
- Flink的DataSource三部曲之三:自定義
- Flink的DataSource三部曲之一:直接APIAPI
- spring boot 與 mybatis-plus 專案出現Debug啟動非常緩慢,{dataSource-1,defaultDruid} inited 要40s左右Spring BootMyBatisUI
- 修改表名時遇到ORA-14047錯誤
- 使用 requests 建立 Cookies 時遇到“系統不知道 filename 哪來的”錯誤,如何修復?Cookie
- 小程式錯誤:Component is not found in path
- Flink的DataSource三部曲之二:內建connector
- github上傳遇到的錯誤Github