Spring Boot : Error creating bean with name 'jpaMappingContext': java.lang.NullPointerException

前端 未结 4 1405
太阳男子
太阳男子 2021-02-07 09:20

My combination of is Spring Boot + Spring Data Jpa + Multiple Databases. I am getting following NullPointer exception when starting the application. Feels like SPring Data with

4条回答
  •  悲&欢浪女
    2021-02-07 10:15

    I faced the mentioned issue with mapping in OnetoOne relationship..

    My app had the following OneToOne relationship.

    A ||---|| B
    
    B ||---|| C
    
    Since its OnetoOne, I kept entity B primary key same as entity A, using @MapsId as mentioned here 
    
    https://vladmihalcea.com/the-best-way-to-map-a-onetoone-relationship-with-jpa-and-hibernate/
    
    Similarly I kept entity C primary key same as entity B.
    
    

    I fixed this by changing the relationship like this

    A ||---|| B
    
    A ||---|| C
    

提交回复
热议问题