Failed to determine a suitable driver class

错误详情:

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
  6. Reason: Failed to determine a suitable driver class
  7. Action:
  8. Consider the following:
  9. If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
  10. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
  11. Process finished with exit code 1

错误原因:
没有使用到DataSource,但是在pom.xml里引入了mybatis-spring-boot-starter

解决方案:

  1. 删除掉mybatis-spring-boot-starter依赖引入
  2. 把spring boot自动初始化DataSource相关的代码禁止掉

关于第二种方案,禁止的办法有两种:

  1. 在启动类的@SpringBootApplication加上

    1. @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
  2. application.properties里配置:

    1. 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

错误详情:

  1. [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

错误原因:

  1. 没有启动Redis Server
  2. 引入了 spring-boot-starter-data-redis 却没有配置

解决方案:

  1. 针对原因1,启动Redis Server
  2. 针对原因2,删除掉spring-boot-starter-data-redis依赖引入