Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introducing JPA into SpringBoot development project can't find the solution of findOne.

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you the SpringBoot development project to introduce JPA can not find findOne solution, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.

Cannot find findOne method by introducing JPA

After developing the DAO layer of SpringBoot, when I went to test it, I found that the method findOne () could not be found. I checked that the corresponding table field name was consistent with the attributes of the entity class.

After searching for a long time, I couldn't find the reason, but finally I found that there was something wrong with the dependent version.

Org.springframework.boot spring-boot-starter-parent 2.0.0.RELEASE

When this is changed to 1.5.10, it can be introduced normally.

Org.springframework.boot spring-boot-starter-parent 1.5.10.RELEASE

For the record, it took three hours to find the problem.

Error report of findOne () method in SpringDataJpa

Today, I watched the springboot video of Mutu.com, and then tapped it myself, and found a problem, that is, I don't have the findOne (Integer id) method.

So I can't use this method to query according to id.

Later, I searched the Internet and found that this has something to do with the jar version of jpa.

Spring-boot-starter-data-jpa

With version 1.11 of SpringDataJPA, you can use the findOne () method to query by id. (said on the Internet)

The version I am using is 2.0.3.RELEASE, and there is no findOne (Integer id) method, but you still want to query according to id, so what should I do?

Solution method

Use findById (id). Get () to make the query.

The above content is the SpringBoot development project to introduce JPA can not find the solution to findOne, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report