spring兼容mysql_springboot 最新版本支持 mysql6.0.6吗
縹緲止盈
1.首先在pom文件中加入下列依賴(lài),一個(gè)使用jpa所需依賴(lài),一個(gè)連接MySQL使用的依賴(lài):mysqlmysql-connector-javaorg.springframework.bootspring-boot-starter-data-jpa 123456789102.在配置文件中添加datasource配置和jpa配置,在mysql中已經(jīng)提前創(chuàng)建了一個(gè)名為db_test的數(shù)據(jù)庫(kù):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:設(shè)為create表示每次都重新建表show-sql: true 123456789103.創(chuàng)建一個(gè)Student bean,包含三個(gè)字段,id name和age,其中id設(shè)置為自動(dòng)增長(zhǎng),bean需要使用@Entity注解,并且聲明一個(gè)無(wú)參的構(gòu)造函數(shù)://需要使用@Entity注解@Entitypublic class Student {//自增ID@Id@GeneratedValueprivate Integer id;private String name;private Integer age;//需要聲明無(wú)參數(shù)的構(gòu)造函數(shù)public Student(){ }public Integer getId() {return id;}public void setId(Integer id) {this.id = id;
總結(jié)
以上是生活随笔為你收集整理的spring兼容mysql_springboot 最新版本支持 mysql6.0.6吗的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 安邦盈泰5号是不是骗局
- 下一篇: mongoose换成mysql_Pack