縹緲止盈
1.首先在pom文件中加入下列依賴,一個使用jpa所需依賴,一個連接MySQL使用的依賴:mysqlmysql-connector-javaorg.springframework.bootspring-boot-starter-data-jpa 123456789102.在配置文件中添加datasource配置和jpa配置,在mysql中已經提前創建了一個名為db_test的數據庫:spring:datasource:driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/db_testusername: rootpassword: rootjpa:hibernate:ddl-auto: create #ddl-auto:設為create表示每次都重新建表show-sql: true 123456789103.創建一個Student bean,包含三個字段,id name和age,其中id設置為自動增長,bean需要使用@Entity注解,并且聲明一個無參的構造函數://需要使用@Entity注解@Entitypublic class Student {//自增ID@Id@GeneratedValueprivate Integer id;private String name;private Integer age;//需要聲明無參數的構造函數public Student(){ }public Integer getId() {return id;}public void setId(Integer id) {this.id = id;