Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2222

Java Spring Boot no bean found using @Bean annotation on default methods

$
0
0

I'm having this error:

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

I have tried a lot of things from browsing the web and nothing seems to work.

Im running Redis at port 6379 on ubuntu and this is my java config file:

import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.data.redis.connection.RedisStandaloneConfiguration;import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;import org.springframework.data.redis.core.RedisTemplate;import restsimulator.cpo.dto.Version;@Configurationpublic class Config {    @Bean    JedisConnectionFactory jedisConnectionFactory() {        RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration("localhost", 6379);        return new JedisConnectionFactory(redisStandaloneConfiguration);    }    @Bean    RedisTemplate<String, Version> redisTemplate() {        RedisTemplate<String, Version> redisTemplate = new RedisTemplate<>();        redisTemplate.setConnectionFactory(jedisConnectionFactory());        return redisTemplate;    }}

These are the dependencies:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis-reactive</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId><exclusions><exclusion><groupId>io.lettuce</groupId><artifactId>lettuce-core</artifactId></exclusion></exclusions></dependency><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId></dependency>

What am I missing here?

EDIT: As M. Deinum suggested in the comments, it was a problem with JPA classpath which triggers the setup of a JDBC DataSource. After removing this from my POM file:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency>

The error no longer occurs. Thanks for helping.


Viewing all articles
Browse latest Browse all 2222

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>