我使用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>
创建了RedisConfig类,其中包含Beans 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在localhost上的计算机上工作。
application.properties
:
spring.redis.host=localhost
spring.redis.port=6379
为什么会出现此错误?
答案 0 :(得分:1)
有几个问题:
spring-boot-starter-redis
已弃用。请改用spring-boot-starter-data-redis
。spring-boot-starter-data-jpa
依赖项。 Spring Data Redis不支持JPA,也不需要它。这实际上是导致您的错误。