Mysql org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取结果集;
类实体Mysql org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取结果集;,mysql,spring-data,Mysql,Spring Data,类实体 @Entity @Table public class Camera { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; private String place; private String address; public Long getId
@Entity
@Table
public class Camera {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String place;
private String address;
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getPlace() {
return place;
}
public void setId(Long id) {
this.id = id;
}
//Constructors, getters and setters are not shown here
}
application.properties配置文件
spring.datasource.url= jdbc:mysql://localhost:3306/springbootdb
spring.datasource.username=root
spring.datasource.password=
server.port=9000
我有这个错误
我必须在数据库中手动创建表才能工作:(知道吗?配置文件中有问题吗?感谢您的帮助:)在
应用程序中添加以下属性。属性文件:
spring.jpa.hibernate.ddl-auto=update
这将初始化您的数据库。根据spring文档,还可以查看其他属性:
我有getter和setter:(更新的答案。请尝试。现在应该可以初始化您的数据库了。谢谢,我非常感谢您的帮助:D,它现在可以工作了:DHi,在自动创建一个表之后,我尝试添加另一个列,它会导致此错误。有什么想法吗?org.springframework.beans.factory.BeanCreationException:创建名为“entityManagerFactory”的bean时出错'在类路径资源[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]中定义]:初始化方法调用失败;嵌套异常为javax.persistence.PersistenceException:[PersistenceUnit:default]无法构建Hibernate SessionFactory
spring.jpa.hibernate.ddl-auto=update