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

Java Spring MVC redis issue in Redis Cache manager

$
0
0

I m trying to use Redis in Spring MVC. I have added Redis cache dependencies in pom.xml created configuration file for Redis but it keeps throwing error. Please see the error below.

`The type org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager cannot be resolved. It is indirectly referenced from required type org.springframework.data.redis.cache.RedisCacheManager`

This error is generated from the configuration file below:

    import org.springframework.context.annotation.Bean;    import org.springframework.context.annotation.Configuration;    import org.springframework.data.redis.cache.RedisCacheManager;    import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;    import org.springframework.data.redis.core.RedisTemplate;    import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;    import org.springframework.data.redis.serializer.StringRedisSerializer;    @Configuration    public class RedisConfig {        @Bean        public JedisConnectionFactory jedisConnectionFactory() {            JedisConnectionFactory factory = new JedisConnectionFactory();            factory.setHostName("");            factory.setPort(");            factory.setPassword("");            return factory;        }        @Bean        public RedisTemplate<String, Object> redisTemplate() {            RedisTemplate<String, Object> template = new RedisTemplate<>();            template.setConnectionFactory(jedisConnectionFactory());            template.setKeySerializer(new StringRedisSerializer());            template.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));            return template;        }        @Bean        public RedisCacheManager cacheManager() {            RedisCacheManager cacheManager = RedisCacheManager.builder(jedisConnectionFactory()).build(); // The erorr is generated on this line            return cacheManager;        }    }`

The error is generated on this code below:

        @Bean        public RedisCacheManager cacheManager() {            RedisCacheManager cacheManager = RedisCacheManager.builder(jedisConnectionFactory()).build(); // The erorr is generated on this line            return cacheManager;        }

My pom.xml:

<?xml version="1.0" encoding="UTF-8"?><project ><modelVersion>4.0.0</modelVersion><groupId>xxxx</groupId><artifactId>xxxx</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><name>xxxx Maven Webapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><hsqldb.version>1.8.0.10</hsqldb.version><failOnMissingWebXml>false</failOnMissingWebXml></properties><dependencies><!-- spring dependency --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.2.0.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-orm</artifactId><version>5.2.0.RELEASE</version></dependency><!-- jstl dependency --><!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --><!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version><scope>provided</scope></dependency><!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp --><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.0.0-alpha01</version></dependency><!-- Spring Security Artifacts - START --><!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web --><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-core</artifactId><version>5.4.1</version></dependency><!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web --><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-web</artifactId><version>5.4.1</version></dependency><!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api --><dependency><groupId>javax.xml.ws</groupId><artifactId>jaxws-api</artifactId><version>2.1</version></dependency><!-- Spring Boot Starter Data Redis --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId><version>2.5.2</version></dependency></dependencies></project>

Please help me out. I m just a beginner and i cant understand how to resolve this issue and use redis. Thanks.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



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