Redis as cache in connect app

I wanted to use redis as cache for the plugin, but encountered some problems while trying to use. As it is instructed in spring documentation I added spring-boot-starter-data-redis and jedis dependencies and let the spring boot to autoconfigure it.
Even though, I have disabled redis for repositories, it getting same error ("Spring Data JPA - Could not safely identify store assignment for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository. ") only for AtlassianHostRepository.

spring:
data:
redis:
repositories:
enabled: false

Is there anyone who faced this before?
Thank you.

@MesutCan, I have seen plenty of problems related to AtlassianHostRepository, but not this one. I had a quick look at it yesterday, but couldn’t get the repository scanning to work properly. It definitely should be possible. As a last resort, creating a sub-interface of AtlassianHostRepository with JPA-specific markers, as the error message suggests, should work, I think…

I will try to find some time next week to have another look, mostly because I’m curious. This really is a general Spring Data + Spring Boot problem, so Stack Overflow seems like a good bet :slight_smile:

If you come up with a solution yourself, please post it back here for reference.

1 Like

Any resolution to this? I get this error too. It works fine with Ehcache but not Redis.

@CommanderBass it’s natural that this problem doesn’t manifest with Ehcache, since Ehcache does not have a Spring Data implementation.

The full error message referenced above contains more details on my suggestion:

RepositoryConfigurationExtensionSupport : Spring Data JPA - Could not safely identify store assignment
    for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository;
    If you want this repository to be a JPA repository,
    consider annotating your entities with one of these annotations:
        javax.persistence.Entity, javax.persistence.MappedSuperclass (preferred),
    or consider extending one of the following types with your repository: 
        org.springframework.data.jpa.repository.JpaRepository

But looking further into that error message, I see this block in the same class (RepositoryConfigurationExtensionSupport):

boolean qualifiedForImplementation = !strictMatchesOnly || configSource.usesExplicitFilters()
        || isStrictRepositoryCandidate(metadata);

Having multiple Spring Data implementations, e.g. JPA and Redis, on the class-path makes Spring Data enter strict mode, per an earlier log message from the same class:

Multiple Spring Data modules found, entering strict repository configuration mode

As the error message describes, AtlassianHostRepository is not a strict repository candidate.

The remaining option of the three in the or condition is for the RepositoryConfigurationSource to use explicit filters, which also seems to work (although it seems a bit hacky):

@EnableJpaRepositories(basePackageClasses = {AtlassianHostRepository.class}, excludeFilters = @ComponentScan.Filter)

I don’t see us solving this in atlassian-connect-spring-boot, since we don’t want to prescribe a specific Spring Data implementation. So when you use more than one, you need to somehow tell Spring Data in your app what implementation to use for AtlassianHostRepository.