老师,单元测试productDao和productImgDao时都报了这个错误,但是我查看了数据库,这个外键是成功的,不知道要怎么解决?



org.springframework.dao.DataIntegrityViolationException:
o2o.tb_product_img, CONSTRAINT fk_proimg_product FOREIGN KEY (product_id) REFERENCES tb_product (product_id))o2o.tb_product_img, CONSTRAINT fk_proimg_product FOREIGN KEY (product_id) REFERENCES tb_product (product_id)); SQL []; Cannot add or update a child row: a foreign key constraint fails (o2o.tb_product_img, CONSTRAINT fk_proimg_product FOREIGN KEY (product_id) REFERENCES tb_product (product_id)); nested exception is java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (o2o.tb_product_img, CONSTRAINT fk_proimg_product FOREIGN KEY (product_id) REFERENCES tb_product (product_id))
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程