Spring Data JPA Error for 1.7.0.M1 query lookup strategy Exception - spring

I was trying to Integrate Spring Data JPA with custom queries added in my repository.The following error made me crazy
"You have defined query method in the repository
but you don't have no query lookupstrategy defined.
The infrastructure apparently does not support query methods!"
Can Anyone tell me how to solve this?

Upgrade the spring-data-commons dependency to 1.9.0.RELEASE.
<!-- Spring Data JPA -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.9.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.0.RELEASE</version>
</dependency>

It was solved when downgraded to 1.6.2.RELEASE
<!-- Spring Data JPA -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<!-- <version>1.7.0.M1</version> -->
<version>1.6.2.RELEASE</version>
</dependency>

Related

Getting "Finished Loading Resource Information. Rendering Swagger UI..." on loading swagger after migration from spring to sprinboot

We just migrated our application from Spring to Sprinboot (2.7.0). whenever i load swagger, all the apis dont get loaded and i get this line "Finished Loading Resource Information. Rendering Swagger UI..." on the top.
But http://host:port/v2/api-docs loads all the apis.
earlier we have below swagger related dependencies in our pom.xml
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${version.io.springfox}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.8</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.8</version>
</dependency>
dependencies. I tried with that, i got same issue.
Later i tried adding springfox-boot-starter dependency and commenting out specific swagger based spring dependencies but no luck. I tried to search for a solution but couldnt find anything concrete.
Any idea why this is happening?

'io.github.resilience4j.common.retry.configuration.RetryConfigurationProperties$InstanceProperties' has no property 'register-health-indicator'

Any help or hint would be greatly appreciated it!!
I am using spring boot 2.5.8.
In my application.properties:
resilience4j.retry.configs.default.registerHealthIndicator= true
I get the following error:
'io.github.resilience4j.common.retry.configuration.RetryConfigurationProperties$InstanceProperties' has no property 'register-health-indicator'
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-circuitbreaker</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-timelimiter</artifactId>
</dependency>
If you wanted to see health, events etc. of any resilience4j patterns below config will be sufficient;
management.endpoint.health.show-details = always

Spring Data MongoDB 1.10.13 and Mongo 3.4

I'm trying to upgrade from Mongo 3.2 to Mongo 3.4. I updated my POM to use the latest Spring Data MongoDB (1.10.13) and while doing so, I noticed Spring Data MongoDB is still being compiled/depended on the old MongoDB Java driver (2.14.3). Since my project is dependent on the Spring Data MongoDB and MongoDB 3.4 driver, I ended up having 2 MongoDB drivers in my libs, which seems to have caused problems.
I ended up adding an exclusion in my POM. Is this the right way to go? How should I override the old MongoDB driver which originates from Spring Data MongoDB 1.10?
This is what my POM looks like:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.4.3</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.10.13.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
</exclusions>
</dependency>

Spring Boot for JPA support

I found only adding properties scanBasePackages on #SpringBootApplication can not enable feature of JPA on #Enity and JpaRepository. I have to add #EnableJpaRepositories and #EntityScan and basePackages properties on them. Is there any simpler solution on this? Thank you
Just go to the Spring Initializr site, specify your 'Group' and 'Artifact' (or live default ones), in the 'Dependencies' block choose "JPA" and "H2" (or another DB you need - see 'Switch to the full version' link), then click 'Generate Project'.
In the downloaded archive you can find the Spring Boot skeleton project with JPA support.
If you look into project pom.xml file you can see these dependencies:
<dependencies>
<!-- JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- H2 DB -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- Other suff -->
</dependencies>
You will have to add those annotations to tell Spring container you want to enable the jpa features.
You will also have to add the following depenencies in your pom.xml to enable spring-data-jpa.
<!-- JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
Check out this GitHub project.

java.lang.NoSuchMethodError: org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.registerIfNotAlreadyRegistered

I am using CRUDRepository to perform crud operations using JPA , but I am getting this error:
java.lang.NoSuchMethodError:
org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.registerIfNotAlreadyRegistered
Please help.
It comes from this commit:
https://github.com/spring-projects/spring-data-commons/commit/6677612f8eac7a7ab67206a5709b6e94cc51028b
So you'll need at least spring-data-commons 1.10.0.RELEASE:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.10.0.RELEASE</version>
</dependency>
But: if this is happening is probably because you've a conflict between versions, so it's better if you find out why you are loading an older spring-data-commons
I was able to solve this error , earlier i was using spring-data-jpa.1.7.2.RELEASE.jar , now i switched on to spring-data-jpa.1.6.0.RELEASE.jar and it solved the problem
thanks for help.
Often this happens when you have 2 dependencies in your maven pom.xml file with the same "groupId" but different versions.
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons-core -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.11.1.RELEASE</version>
</dependency>
Common "groupId"'s should have the same version number.

Resources