spring - BeanCreationException:创建类路径资源中定义的名称为“entityManagerFactory”的bean时出错
问题描述
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/me/Downloads/Student-API-2.0/target/classes/data.sql]: insert into Student values(17,"Nil","aj@gmail.com"); nested exception is org.h2.jdbc.JdbcSQLException: Column "Nil" not found; SQL statement:
insert into Student values(17,"Nil","aj@gmail.com") [42122-197]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
Caused by: org.h2.jdbc.JdbcSQLException: Column "Nil" not found; SQL statement:
insert into Student values(17,"Nil","aj@gmail.com") [42122-197]
解决方案
您可以在 sql 语句中指定列的名称,以确保它不会与列名称不匹配的值。
insert into Student(column1, column2, column3) values(17,'Nil','aj@gmail.com')
推荐阅读
- javascript - Openlayers 6.4 如何在每次点击相同功能时触发选择事件?
- swiftui - 如何从 SwiftUI 2.0 中的多个其他视图访问和编辑 @AppStorage 变量?
- apache-kafka - 如何检查主题 Kafka 是否被清除
- python - 打开涉及jupyter笔记本的存储库时如何设置项目根文件夹
- excel - Excel 中的 Sigma 求和累加值
- asp.net - .NET Core 中间件“set-cookie”响应中的反向代理未在浏览器中设置,也未在 HttpResponseMessage 中显示
- swagger-ui - 在 Swagger UI 中,如何在新窗口中打开响应?
- python - 使用 Apache Beam Python `WriteToFiles` 转换每个窗口只写入一个文件
- php - 如何在 Moodle 网站上嵌入缩放视频?
- jmeter - 我想在 JMeter 中当 thread(user number)=10000 时达到 10000 rps,我该如何实现这个目标?