错误:Unable to execute schema management to JDBC target[alter table ** add column ** integer not null]

SpringJPA问题

  • 问题描述

在使用SpringJPA进行自动生成表的时候报错
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [springJpa.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [alter table student add column sid integer not null]


  • 解决

在对应的实体类上添加 @Table(name = "teacher",catalog = "databaseName")databaseName是我连接的数据库名

原因:

可能是因为 添加表 已存在。这是因为hibernate扫描时可能不止扫描当前的database

发布了31 篇原创文章 · 获赞 25 · 访问量 6489

猜你喜欢

转载自blog.csdn.net/qq_43719932/article/details/103433154