我使用 Spring Boot 和 Redis。我添加了 pom.xml
:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
并创建了包含 Beans 的 RedisConfig 类 JedisConnectionFactory jedisConnectionFactory
和 RedisTemplate< String, Object > redisTemplate()
.
当我运行应用程序时,出现错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
我不使用嵌入式 Redis。 Redis 在本地主机上的我的计算机上工作。
application.properties
:
spring.redis.host=localhost
spring.redis.port=6379
为什么会出现这个错误?
最佳答案
有几个问题:
spring-boot-starter-redis
已弃用。请改用spring-boot-starter-data-redis
。- 删除
spring-boot-starter-data-jpa
依赖项。 Spring Data Redis 不支持 JPA,也不需要它。这实际上导致了您的错误。
关于java - 无法在 Spring Boot 中使用 Redis 确定数据库类型 NONE 的嵌入式数据库驱动程序类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44874928/