【发布时间】:2020-06-06 20:56:24
【问题描述】:
请注意,此代码确实适用于普通 Spring,但不适用于 Spring Boot(v1.3.3),我是否缺少某些东西,因为这是从有效的 spring 应用程序导入的。下面的代码来自spring boot app
@Entity
@Table(name="project")
public class Project implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private int id;
@Column(name="teamId")
private int teamId;
//private String Rentabiliteit;
@Column
//@Index(name="IProject_status",columnNames="Status")
private String status;
@Column
//@Index(name="IProject_naam",columnNames="Naam")
private String naam;
//public Prototype m_Prototype;
//public Team m_Team;
}
SQL
CREATE TABLE IF NOT EXISTS `project` (
`id` int(11) NOT NULL,
`teamId` int(11) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`naam` varchar(255) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
错误
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Unknown column 'project0_.team_id' in 'field list'
已编辑:Application.yml
spring:
mvc:
view:
prefix: /WEB-INF/jsp/
suffix: .jsp
datasource:
url: jdbc:mysql://localhost:3306/oxyplast
username: oxyplastuser
password: oxyplastuserpw
jpa:
properties:
hibernate:
current_session_context_class: org.springframework.orm.hibernate4.SpringSessionContext
namingStrategy: org.hibernate.cfg.DefaultNamingStrategy
【问题讨论】:
-
我怀疑问题是否出在您发布的代码中。你能发布完整的堆栈跟踪吗?
-
@MadhusudanaReddySunnapu 这太长了,但我这是造成问题的原因
-
查看了域包。 Project 是唯一被注释为实体的类。剩下的都是普通班。这是正确的吗?您可以发布其中包含根本原因字符串的部分堆栈跟踪吗?
-
这个github线程很有用:github.com/spring-projects/spring-boot/issues/2129
标签: hibernate spring-boot