spring-boot - 我无法在 h2 数据库中创建表
问题描述
我正在做一个图书馆管理的小项目。所以,为此我从这个简单的东西开始添加细节并获取它们。当我使用 h2 数据库时,我没有创建表。这是我的代码。有人可以解决它。
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name ="library")
@Entity
public class Book {
@Id
private int id;
private String author;
private String title;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return "Book [id=" + id + ", author=" + author + ", title=" + title + "]";
}
解决方案
确保您的application.properties
文件具有以下属性。
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/dbname
推荐阅读
- python - builtin_function_or_method 不支持的操作数类型
- python - python中`curvefit()`模块背后的理论
- android - ConstraintLayout - 只有一侧受约束的 match_constraint 的行为
- c# - C# 游戏与代表打勾
- ios - 在 UIScrollView 中检测 UIImageView 上的点击
- php - 在数组中包含文件 - PHP
- xamarin - xamarin android,无法将drawable从另一个类转换为位图
- google-cloud-platform - 为 gcloud 服务帐号分配范围
- c# - 更改以前保存的数组
- c - 关于#if defined(宏名)的问题