首页 > 解决方案 > 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]

在此处输入图像描述

在此处输入图像描述

标签: springrest

解决方案


您可以在 sql 语句中指定列的名称,以确保它不会与列名称不匹配的值。

insert into Student(column1, column2, column3) values(17,'Nil','aj@gmail.com')

推荐阅读