Failed to determine a suitable driver class
错误详情:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
错误原因:
没有使用到DataSource,但是在pom.xml里引入了mybatis-spring-boot-starter
解决方案:
- 删除掉
mybatis-spring-boot-starter
依赖引入 - 把spring boot自动初始化DataSource相关的代码禁止掉
关于第二种方案,禁止的办法有两种:
在启动类的
@SpringBootApplication
加上@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
在
application.properties
里配置:spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
参考:
SpringBoot启动报错Failed to determine a suitable driver class
Unable to connect to localhost/:6379
错误详情:
[org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379
错误原因:
- 没有启动Redis Server
- 引入了
spring-boot-starter-data-redis
却没有配置
解决方案:
- 针对原因1,启动Redis Server
- 针对原因2,删除掉
spring-boot-starter-data-redis
依赖引入