spring boot mysql配置
来源:互联网 发布:云计算中saas是啥意思 编辑:程序博客网 时间:2024/05/16 11:04
在任何一个平台都逃离不了数据库的操作,那么在spring boot中怎么接入数据库呢?
很简单,我们需要在application.properties进行配置一下,application.properties路径是src/main/resources下,对于application.properties更多的介绍请自行百度进行查找相关资料进行查看,在此不进行过多的介绍,以下只是mysql的配置文件。
大体步骤:
(1)在application.properties中加入datasouce的配置
(2)在pom.xml加入mysql的依赖。
(3)获取DataSouce的Connection进行测试。
src/main/resouces/application.properties:
1
2
3
4
5
6
7
8
9
10
11
########################################################
###datasource
########################################################
spring.datasource.url = jdbc:mysql://localhost:3306/test
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.max-active=20
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=10
pom.xml配置:
1
2
3
4
<
dependency
>
<
groupId
>mysql</
groupId
>
<
artifactId
>mysql-connector-java</
artifactId
>
</
dependency
>
到此相关配置就ok了,那么就可以在项目中进行测试了,我们可以新建一个class Demo进行测试,实体类创建完毕之后,我们可能需要手动进行编写建表语句,这时候我们可能就会想起Hibernate的好处了。那么怎么在spring boot使用Hibernate好的特性呢?So easy,具体怎么操作,请看上篇文章之JPA – Hibernate。
阅读全文
0 0
- spring boot mysql配置
- SpringBoot:spring boot mysql配置
- CentOS7配置MySQL、Nginx、Spring Boot
- spring-boot结合mysql配置数据库连接池
- Spring boot + mysql +mybatis 配置整合实例
- Spring Boot 学习第二步 配置MySQL数据库+JPA
- Spring Boot 学习第二步 配置MySQL数据库+JPA
- Spring Boot 学习第二步 配置MySQL数据库+JPA
- Spring Boot访问mysql(JPA方式)最简单配置
- spring boot + gradle + mysql
- spring boot设定mysql
- Spring boot结合Mysql
- spring-boot集成mysql
- 配置spring boot工程
- Spring Boot 配置log4j
- Spring boot配置cache
- Spring-boot 配置log4j
- SPRING BOOT 配置大全
- A
- linux find命令-print0和xargs中-0使用技巧(转载)
- POJ1703 两种方法
- 嵌入式工具——iperf
- XListview上拉刷新,下拉加载
- spring boot mysql配置
- caffe基础-03池化层的配置
- Maximum Sequence(hdu 6047)
- 安卓开发傻瓜入门之搭建android应用开发环境
- gcd (辗转相除) 一般用于求最大公约数 最小公倍数
- js 与 android 交互
- 使用Axure制作App原型应该怎样设置尺寸?
- 1073约瑟夫环
- Pythoon爬虫之requests库学习