Error after dependency of Redis (spring-boot-starter-data-redis) added in spring-boot

3.3k views Asked by At

When I add below dependency to pom.xml

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

Below error comes

2018-05-31 12:02:38.217 INFO 1416 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2018-05-31 12:02:39.233 ERROR 1416 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'registerCorePageControllerServlet' defined in com.amd.apps.employee.cloud.AddonApplication: Unsatisfied dependency expressed through method 'registerCorePageControllerServlet' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authenticationContextImpl' defined in URL [jar:file:/C:/Users/shiv/AppData/Local/Temp/employee.cloud-1.0.0.jar-spring-boot-libs-1766ddea-c2ae-424e-9565-d00395eb0d5c/core.cloud-1.0.0.jar!/com/amd/apps/cloud/service/common/AuthenticationContextImpl.class]: Unsatisfied dependency expressed through constructor parameter 3; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'companyServiceImpl' defined in URL [jar:file:/C:/Users/shiv/AppData/Local/Temp/employee.cloud-1.0.0.jar-spring-boot-libs-1766ddea-c2ae-424e-9565-d00395eb0d5c/core.cloud-1.0.0.jar!/com/amd/apps/cloud/service/directory/impl/CompanyServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.atlassian.connect.spring.AtlassianHostRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

However if i remove this dependency, everything works perfectly. Redis service is configured, running and accessible. However i see below messages as well, which i do not see during normmal execution

2018-05-31 12:02:28.955 INFO 1416 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2018-05-31 12:02:29.071 INFO 1416 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data JPA - Could not safely identify store assignment for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository. 2018-05-31 12:02:29.171 INFO 1416 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!

2

There are 2 answers

1
Rohan Shrivastava On

The message you are encountering is not an error; it is merely a suggestion from Redis. It suggests configuring your repositories with Redis cache. If you decide to implement Redis support in your repository, you can ignore the message, and it will disappear after initializing your repositories.

However, if you do not intend to add Redis support to your repository and prefer to remove these suggestions from your console when starting your application, you can utilize the following code snippet. Place it in the main class of your application:

@EnableAutoConfiguration(exclude = RedisRepositoriesAutoConfiguration.class)

This code excludes the RedisRepositoriesAutoConfiguration class from the automatic configuration process, effectively eliminating the Redis-related suggestions from your console output.

0
Subhash Verma On

The problem is caused by RedisRepositoriesAutoConfiguration. It registers EnableRedisRepositories repeatedly only with default config, which with empty basePackages. To solve the problem, you could exclude RedisRepositoriesAutoConfiguration by:

@SpringBootApplication(
    exclude = { RedisRepositoriesAutoConfiguration.class })