错误org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名为“entityManagerFactory”的bean时出错

2024-04-30

我想将我的 java CRUD 应用程序与红色节点连接。但当我运行 Java 应用程序时,我总是收到此错误。我试图解决它,但我不能。 这是错误:

2022-05-10 11:33:43.959  INFO 12192 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-05-10 11:33:43.969  INFO 12192 --- [  restartedMain] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-05-10 11:33:43.988 ERROR 12192 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

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/iratx/Documents/MU/2020/segundo%20semestre/PBL6Xabi/produktua/crudrest-api/muraicrud/target/classes/data.sql]: REPLACE INTO `roles` VALUES (1,'ADMIN'); nested exception is java.sql.SQLException: Column count doesn't match value count at row 1
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:610) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.6.jar:5.3.6] 
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) 
~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.5.jar:2.4.5]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) ~[spring-boot-2.4.5.jar:2.4.5]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) ~[spring-boot-2.4.5.jar:2.4.5]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-2.4.5.jar:2.4.5]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) ~[spring-boot-2.4.5.jar:2.4.5]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) ~[spring-boot-2.4.5.jar:2.4.5]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) ~[spring-boot-2.4.5.jar:2.4.5]
        at com.example.CrudApplication.main(CrudApplication.java:10) ~[classes/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.5.jar:2.4.5]      
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/iratx/Documents/MU/2020/segundo%20semestre/PBL6Xabi/produktua/crudrest-api/muraicrud/target/classes/data.sql]: REPLACE INTO `roles` VALUES (1,'ADMIN'); nested exception is java.sql.SQLException: Column count doesn't match value count at row 1
        at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:622) ~[spring-jdbc-5.3.6.jar:5.3.6]
        at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254) ~[spring-jdbc-5.3.6.jar:5.3.6]
        at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49) ~[spring-jdbc-5.3.6.jar:5.3.6]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202) ~[spring-boot-autoconfigure-2.4.5.jar:2.4.5]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:119) ~[spring-boot-autoconfigure-2.4.5.jar:2.4.5]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:91) ~[spring-boot-autoconfigure-2.4.5.jar:2.4.5]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:38) ~[spring-boot-autoconfigure-2.4.5.jar:2.4.5]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.6.jar:5.3.6]
        at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:111) ~[spring-boot-autoconfigure-2.4.5.jar:2.4.5]
        at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:102) ~[spring-boot-autoconfigure-2.4.5.jar:2.4.5]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[spring-beans-5.3.6.jar:5.3.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.6.jar:5.3.6]
        ... 21 common frames omitted
Caused by: java.sql.SQLException: Column count doesn't match value count at row 1
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.23.jar:8.0.23]
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.23.jar:8.0.23]
        at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:762) ~[mysql-connector-java-8.0.23.jar:8.0.23]
        at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:646) ~[mysql-connector-java-8.0.23.jar:8.0.23]
        at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) ~[HikariCP-3.4.5.jar:na]
        at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-3.4.5.jar:na]
        at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:601) ~[spring-jdbc-5.3.6.jar:5.3.6]
        ... 37 common frames omitted

我已经尝试过在线浏览,但无法修复它。我知道它说它执行 SQL 脚本失败,但我的 SQL 中只有一个带有 roleId 和名称的表。因此,我尝试使用双关语 INSERT INTO 而不是 Replace,但出现了相同的错误。

这是sql语句:

create table roles(
id INT NOT NULL,
name VARCHAR(30) NOT NULL
)

谢谢


也许您正在连接到不同的数据库。在该数据库中roles表的列数多于/少于 2 列。

而不是这行代码REPLACE INTO roles VALUES (1,'ADMIN') in data.sql文件尝试指定exact查询中的列名称:

REPLACE INTO roles(id,name) VALUES (1,'ADMIN');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名为“entityManagerFactory”的bean时出错 的相关文章

随机推荐

  • 即使禁用缓存,Safari 也会缓存 GET 请求

    我已经将我所知道的所有标头设置为在我的服务器上禁用缓存 甚至禁用 ETAG 但 Safari 仍然偶尔 大约 50 次 缓存我的请求 Workflow 我正在实施 oauth 1 所以 浏览器使GET api user request 服务
  • jQuery JSON 请求得到“200 OK”答案,但没有内容

    我正在使用 jQuery 通过访问者的 IP 地址获取其位置 有一项很棒的服务叫做免费地理IP http freegeoip appspot com 我需要做的就是在 URL 末尾添加 json 或 xml 然后添加 IP 地址 它将返回所
  • 如何使用 selenium 获取带有 css 选择器的所有元素的直接子元素?

    我已经尝试过使用 gt 语法 但 selenium 不接受它 我知道有一种方法可以使用 Xpath 获取它 但我们的整个项目是使用 CSS 选择器编写的 我试图存储一个列表 其中包含元素的所有直接子元素 但不包含其子元素 后代 当我使用 语
  • 使 URL W3C 有效并在 Ajax 请求中工作

    我有一个返回 URL 的通用函数 这是一个插件函数 可返回插件内资源 图像 样式表 的 URL 我在这些 URL 中使用 GET 参数 如果我想在 HTML 页面中使用这些 URL 以通过 W3C 验证 我需要将 符号屏蔽为 plugin
  • 我可以使用 VIM 查看 Python 中函数的文档字符串吗?

    在 VIM 中编写 Python 时 有什么方法可以查看函数的文档字符串吗 例如 def MyFunction spam A function that foobars the spam returns eggs return foobar
  • 使用 ImageMagick 从文本生成图像?

    我正在尝试使用 ImageMagick 创建 3840 x 2160 的缩略图 我需要图像具有黑色背景和白色文本 文本应垂直和水平居中 我希望能够设置字体大小 但如果文本超出图像 则会自动减小字体大小 使其适合左侧和右侧的一定量的填充 我将
  • 通过 nginx 入口控制器进行基本身份验证

    我正在使用 nginx 入口控制器 https kubernetes github io ingress nginx deploy https kubernetes github io ingress nginx deploy 在 AWS
  • C++ win32 控制台中的颜色

    std cout lt lt blblabla done lt lt std endl 是否有可能使 done 采用另一种颜色 并且可能是大胆的 我使用的是 Windows 7 这取决于您使用的操作系统 如果您使用的是您想要的 Window
  • Aurelia:创建嵌套/多级导航菜单的简单方法

    我需要创建一个多级导航菜单 菜单的内容根据用户的不同而不同 我计划通过一个以 JSON 形式返回数据的服务来提取可包含子项数组的导航项集合 我见过的每个导航 路由示例都使用静态路由或单级菜单 我已经阅读了一些有关子路由的内容 但这似乎不是我
  • 基于我的 C# 类生成 xml 文件

    我有 xml 文件 每次都需要根据新客户的要求进行更新 大多数时候 xml 不正确是因为手动更新了 xml 文件 我正在考虑编写一个提供适当验证的程序 网络 Windows 并根据 ui 的输入 我将创建 xml 文件 下面是我的示例 xm
  • 内联网应用程序是否需要 SSL 证书

    我的应用程序将使用 MSI 安装程序部署到用户的服务器 并且期望它将作为 Intranet 应用程序在其安全网络上运行 但是 由于我在整个网站上使用 HTTPS 我想知道如何获得有效的证书 我已经使用 MakeCert 生成了一个开发版本
  • BLE 广播帧和 BLE 信标帧有区别吗

    我正在接收EVT LE ADVERTISING REPORT来自 HCI 套接字 我想区分 BLE 信标和普通 BLE 设备 解析设备名称等 我有点困惑是否所有 BLE 设备都会发出信标或者它们是不同的 如果不同 那么它们的数据包格式如何
  • 按第二个值对二维数组进行排序

    好吧 假设我有一个像 z 1 d 3 e 2 这样的数组 如何按每个组成数组的第二个元素对该数组进行排序 这样我的数组就会如下所示 z 1 e 2 d 3 arr z 1 d 3 e 2 arr sort a b a 1 lt gt b 1
  • WCF 中的实例停用是什么?

    我最近接触到这个词Instance Deactivation a 那是什么 b 我们需要这个做什么 c 它在什么情况下有用 我正在寻找一个易于理解的简单答案 如果可能的话 可以使用一些伪代码 Thanks 当调用 WCF 方法时 它会传递给
  • “此时元素 li 上不允许使用属性 aria-expanded”

    我有以下代码 从这里 https www w3 org WAI tutorials menus examples appmenu div ul li File ul li New li ul li ul div
  • useSelector 常量在调度后不更新

    这里有一个代码沙盒 https codesandbox io s competent moon 9ehen getIDs 更新cells 然后需要initializeCells 但是 此更改在分派操作后不会反映出来 尽管如此 我还是可以看到
  • Javascript正则表达式替换多个组

    我正在尝试根据这样的正则表达式替换多个匹配的组 var paramRegex s w s w s w s s i should match group1 group2 group3 var emptyParam emptyParam rep
  • 为页面上的所有 AJAX 请求添加“钩子”

    我想知道是否可以 挂钩 每个 AJAX 请求 无论是即将发送的请求 还是事件上的请求 并执行操作 此时 我假设页面上还有其他第三方脚本 其中一些可能使用 jQuery 而另一些则不使用 这可能吗 注意 接受的答案不会产生实际的响应 因为它被
  • 如何获取日期时间格式的 Win32_OperatingSystem.LastBootUpTime

    我一直在尝试使用 Win32 OperatingSystem 类 WMI 获取 LastBootUpTime HRESULT hr pEnumerator gt Next WBEM INFINITE 1 pclsObj uReturn if
  • 错误org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名为“entityManagerFactory”的bean时出错

    我想将我的 java CRUD 应用程序与红色节点连接 但当我运行 Java 应用程序时 我总是收到此错误 我试图解决它 但我不能 这是错误 2022 05 10 11 33 43 959 INFO 12192 restartedMain