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