After upgrading project spring boot from 2.0.5.RELEASE to 2.1.18.RELEASE and spring framework from 5.0.9.RELEASE to 5.1.20.RELEASE the application got UnsatisfiedDependencyException on boot run:
"Invocation of init method failed; nested exception is java.lang.IllegalStateException: You have defined query method in the repository but you don't have any query lookup strategy defined. The infrastructure apparently does not support query methods!"
This project uses redis as persistence with spring-data-redis and spring-data-jpa with SQL Server. And Redis repository implements query method:
@EnableAspectJAutoProxy
@PropertySource("classpath:/application.properties")
@PropertySource(value = "classpath:application-${project_env:default}.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:/project/application.properties", ignoreResourceNotFound = true)
@EnableRedisRepositories("project.repository.redis")
@Configuration
public class MainConfiguration { }
package project.repository.redis;
import project.domain.redis.hash.SessionRegistry;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
public interface ProjectRedisRepository extends CrudRepository<SessionRegistry, String> {
SessionRegistry findBySessionKey(String sessionKey);
}
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;
import project.domain.enums.SessionStatus;
@RedisHash(timeToLive = 120)
public class SessionRegistry {
@Id
private String id;
@Indexed
private String sessionKey;
private SessionStatus status;
private String token;
public SessionRegistry() {
}
...getters and setters...
build.gradle
dependencies {
...
// In case of Database use
compile "org.springframework.boot:spring-boot-starter-data-jpa:2.1.18.RELEASE"
compile "org.springframework:spring-jdbc:5.1.20.RELEASE"
runtime "com.microsoft.sqlserver:mssql-jdbc:9.1.0.jre11-preview"
compile "com.zaxxer:HikariCP:3.1.0" // connection pool
...
This error only happens when the repository have query method. If we use default CrudRepository methods, there's no problem.
Dependencies:
| +--- org.springframework.boot:spring-boot:2.0.6.RELEASE -> 2.1.18.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter-data-redis:2.0.4.RELEASE -> 2.1.18.RELEASE
| | +--- org.springframework.boot:spring-boot-starter:2.1.18.RELEASE (*)
| | +--- org.springframework.data:spring-data-redis:2.1.21.RELEASE
| | | +--- org.springframework.data:spring-data-keyvalue:2.1.21.RELEASE
| | | | +--- org.springframework.data:spring-data-commons:2.1.21.RELEASE (*)
| +--- org.springframework.data:spring-data-jpa:2.1.21.RELEASE
| | +--- org.springframework.data:spring-data-commons:2.1.21.RELEASE
| | | +--- org.springframework:spring-core:5.1.19.RELEASE (*)
| | | +--- org.springframework:spring-beans:5.1.19.RELEASE (*)
Downgrading Spring Boot and Spring Framework is not an option for this project, due the Cloud Open Feing dependency upgrade and compatibility.