JPA采坑记录
背景
最近在负责一个老产品的维护升级工作,此产品是个高龄产品,据说已经超过了十岁,产品代码结构中有公司自研的内容(已经无人维护),有spring 2.X的版本,有spring 4.X的版本,有ibatis也有jpa。
为了降低以后维护升级工作的难度,决定对产品代码做一次重构,去掉无法维护的自研框架,升级spring,统一持久化层使用jpa。在此过程中则遇到了一些问题在此留痕,希望能帮助到大家。
遇到的问题
1. Field xxxRepository in XXX required a bean of type ‘XXXRepository’ that could not be found.
异常信息:
Description:
Field xxxRepository in XXX required a bean of type 'XXXRepository' that could not be found.
Action:
Consider defining a bean of type 'XXXRepository' in your configuration.
遇到上边的异常信息去网上找一般都会被带到package是否被扫描,@EntityScan @Entity @Repository等注解是否添加上去,但是加上@EntityScan等一些网上的解决方式又引起了一系列其他问题。
后经过分析发现&