搭个Springboot+Jpa环境,一启动就报错:

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table X drop foreign key “FK7x41955roke6bti1oqnvs893h" via JDBC Statement

和:

nested exception is java.lang.IllegalArgumentException: 'script' must not be null or empty

详情如下:

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table X drop foreign key FK7x41955roke6bti1oqnvs893h" via JDBC Statementat org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359)at org.hibernate.tool.schema.internal.SchemaDropperImpl.applyConstraintDropping(SchemaDropperImpl.java:331)at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:230)at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154)at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126)at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112)at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144)at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script from resource [URL [file:/C:/Users/admin/IdeaProjects/ActivitiTest/target/classes/data-mysql.sql]]; nested exception is java.lang.IllegalArgumentException: 'script' must not be null or emptyat org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:530)at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:240)at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:48)at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:210)at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:123)at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:93)at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:37)at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:826)

在网上找帖子,要不说是方言的问题,要不说是”ddl-auto”类型的问题,试了都不管用,一点点试发现是初始化的默认机制的问题。

spring.datasource.initialization-mode=always

mode=always时,代表全部数据初始化,包括数据库和内存数据,而这时在classpath里的data-mysql.sql内的数据会自动录入数据库,而我把它注掉了

这就是报错的原因。

解决办法:取消屏蔽或者干脆删掉这个文件也可以

SpringBoot+JPA 启动建表错误:CommandAcceptanceException: Error executing DDLalter table X drop foreign key相关推荐

  1. mysql外键1050_MYSQL建表错误:ERROR 1050

    MYSQL建表错误:ERROR 1050 关注:193  答案:2  mip版 解决时间 2021-01-17 09:33 已解决 2021-01-16 20:50 五张表: create table ...

  2. 解决Springboot+JPA中多表关联查询会查询多次的问题(n+1查询问题)

    解决Springboot+JPA中多表关联查询会查询多次的问题(n+1查询问题) 参考文章: (1)解决Springboot+JPA中多表关联查询会查询多次的问题(n+1查询问题) (2)https: ...

  3. springboot项目启动时提示错误: 找不到或无法加载主类

    问题: springboot项目启动时提示错误: 找不到或无法加载主类 解决方法:

  4. 错误信息 Error executing DDL via JDBC Statement 解决办法

    二月 27, 2018 10:34:44 上午 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleExceptio ...

  5. 启动Maven程序时报错 Error executing Maven

    启动Maven程序时报错 Error executing Maven 异常信息 [INFO] Error stacktraces are turned on. [ERROR] Error execut ...

  6. 【数据库】ALTER TABLE 语句与 FOREIGN KEY 约束““冲突。该冲突发生于数据库““,表““, column ‘‘。

    摘要:微信搜索[三桥君] 本篇讲述的是在已经创建好表且有数据的情况下,增加 FOREIGN KEY 约束的报错问题 一.问题 当我在一张Student表中增加它的classNo外键,外键参照Class ...

  7. docker export import后,导入镜像,启动时的错误,Error response from daemon: No command specified...

    Docker的流行与它对容器的易分享和易移植密不可分,用户不仅可以把容器提交到公共服务器上,还可以把容器导出到本地文件系统中.同样,我们也可以把导出的容器重新导入到Docker运行环境中.Docker ...

  8. mysql数据库建表错误

    数据库如果出现错误,只是肉眼检查很难发现错误,后来在别人告知的情况下知道了使用其他方法进行检查,现在记录一下. 首先,写的代码在vchar处有错误,但是那时候并不知道. 在建表后打断点,鼠标放在上方就 ...

  9. Flowable 6.4.1数据库自动建表错误 SQLSyntaxErrorException: Table 'flowable.act_id_property' doesn't exist

    跟着官方Demo学flowable6.4.1,在内存里建表没问题,移到数据库建表就报错 请教了大神才知道,是因为之前本机上建过相同的表(Mysql8.0以上版本改成了false),解决办法就是设置默认 ...

最新文章

  1. 从词袋到Transfomer,NLP十年突破史
  2. python的快速入门-Python快速入门
  3. 全局变量引起的BUG
  4. C#中的{n}运算符
  5. python stdout stderr 一起输出_Python在保留顺序的同时分别从子进程stdout和stderr读取...
  6. 当PDF页面总数不确定的时候导出PDF增加页码(i of n)
  7. python元组和列表的联系_Python元组与列表的区别和联系?
  8. 使用Jenkins来实现内部的持续集成流程(下)
  9. 要成为一个 Java 架构师得学习哪些知识以及方法?
  10. java外部类_Java里什么叫内部类什么叫外部类
  11. SVN: Can't create session svn
  12. 微信小程序 3 岁:日活超 3 亿,交易额超 8000 亿
  13. git 代码提交过程
  14. 在OneNote中快速插入当前日期和时间
  15. 自动跳动滑动门html,CSS如何实现滑动门效果_html/css_WEB-ITnose
  16. IDEA web.xml版本过低怎么生成新的
  17. 外包的水有多深?华为15k+的外包测试岗能去吗?
  18. 卸载 mysql 2008_强力卸载SQL Server 2008图文详解
  19. android 方法映射,高通Android平台驱动层 MSM8916 键值映射方法
  20. 产品经理如何进行复盘总结

热门文章

  1. 【步兵 工具篇】lzma算法,压缩字节流
  2. 企业微信应用程序开发WeChatAPI
  3. 国际知名服装品牌网站集合
  4. JavaScript 判断对象中属性的值是否空,如果为空,则删除该属性
  5. cf768G The Winds of Winter 主席树
  6. Win10系统将桌面从C盘移动到其他盘的方法
  7. 从抓包砍到接口测试,五分钟看完全过程解析,还说你不会测试?
  8. xtrabackup 问题“Too many open files”system error number 24
  9. Pycharm中显示Please select a valid Python Interpreter
  10. 一个开源的论坛系统AstalPathTalk