【发布时间】:2022-01-24 15:52:42
【问题描述】:
我想知道如何在启动时创建示例实体以在 Spring Boot 应用程序中测试我的前端。现在我正在尝试使用 CommandLineRunner 但我收到此错误:
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) ~[spring-boot-2.5.0.jar:2.5.0]
at it.uniroma3.siw.SiwSpringSecurityApplication.main(SiwSpringSecurityApplication.java:24) ~[classes/:na]
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : it.uniroma3.siw.spring.model.Intervento.meccanico -> it.uniroma3.siw.spring.model.Meccanico; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : it.uniroma3.siw.spring.model.Intervento.meccanico -> it.uniroma3.siw.spring.model.Meccanico
.... …… ....
这个错误有什么解决办法吗?或者可能有任何其他方式在数据库中创建示例(测试)实体?
【问题讨论】:
标签: java mysql spring database security