使用H2控制台

修改application.properties:

#使用H2控制台

spring.h2.console.enabled=true

 

springboot整合H2

 

http://localhost:8080/h2-console

springboot整合H2

jdbc:h2:mem:testdb

实体类

package com.nrd.domain;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

/**

 * User实体

 */

@Entity // 实体

public class User {

       @Id // 主键

       @GeneratedValue(strategy = GenerationType.IDENTITY) // 自增策略

       private Long id;// 实体唯一标识

       private String name;

       private String email;

 

       protected User() { // 设为protected 防止直接使用

             

       }

 

       public User(Long id, String name, String email) {

              this.id = id;

              this.name = name;

              this.email = email;

       }

 

       //getter and setter

 

       @Override

       public String toString() {

              return "User [id=" + id + ", name=" + name + ", email=" + email + "]";

       }

}

相关文章: