spring boot 使用mysql实例详解
开发阶段用 h2即可,上线时,通过以下配置切换到mysql,spring boot将使用这个配置覆盖默认的h2。
1.建立数据库:
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
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论