Spring boot 使用mysql實(shí)例詳解
開(kāi)發(fā)階段用 H2即可,上線時(shí),通過(guò)以下配置切換到mysql,spring boot將使用這個(gè)配置覆蓋默認(rèn)的H2。
1.建立數(shù)據(jù)庫(kù):
mysql -u root
CREATE DATABASE springbootdb
2.pom.xml:
dependency>
groupId>mysql/groupId>
artifactId>mysql-connector-java/artifactId>
/dependency>
3.application.properties:
spring.datasource.url= jdbc:mysql://localhost:3306/springbootdb
spring.datasource.username=root
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=create-drop//none, validate, update, create-drop
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
您可能感興趣的文章:- Spring Boot Mysql 數(shù)據(jù)庫(kù)操作示例
- Spring Boot如何解決Mysql斷連問(wèn)題
- Spring Boot 添加MySQL數(shù)據(jù)庫(kù)及JPA實(shí)例
- Spring Boot中使用jdbctemplate 操作MYSQL數(shù)據(jù)庫(kù)實(shí)例
- SpringBoot連接MYSQL數(shù)據(jù)庫(kù)并使用JPA進(jìn)行操作
- Spring Boot JPA訪問(wèn)Mysql示例
- SpringBoot用JdbcTemplates訪問(wèn)Mysql實(shí)例代碼
- SpringBoot入門系列之JPA mysql
- 詳解在Spring Boot中使用Mysql和JPA
- Spring Boot高級(jí)教程之Spring Boot連接MySql數(shù)據(jù)庫(kù)