当我运行独立的 Web 应用程序时,Spring 无法实例化数据源 bean。请注意,我不想在这个项目中使用 JPA 或 hibernate。此时我不知道为什么。我最好的猜测是依赖项或语法问题,但我无法找到问题的解决方案。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gameoo' defined in class path resource [com/hf/database/Datasource.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'get' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
Run Code Online (Sandbox Code Playgroud)
如果有人有一些见解或可以帮助我解决这个问题,那就太好了。
下面是我的“spring.properties”文件
# Datasource properties
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/gameoo?autoReconnect=true&useSSL=true
spring.datasource.username = user
spring.datasource.password = pass
spring.datasource.initialSize = 1
spring.datasource.maxActive = 5
# HikariCP settings (spring.datasource.hikari.*)
spring.datasource.hikari.connection-timeout = …Run Code Online (Sandbox Code Playgroud)