我当时在做一个图书馆管理的小项目。因此,为此,我从这个简单的事情开始添加细节并获取它们。我使用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 + "]";
}
答案 0 :(得分:0)
确保您的application.properties
文件具有以下属性。
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/dbname