小言_互联网的博客

Springboot连接数据库

328人阅读  评论(0)

连接mysql数据库

架包


  
  1. <dependency>
  2. <groupId>org.springframework.boot </groupId>
  3. <artifactId>spring-boot-starter-web </artifactId>
  4. </dependency>
  5. <!-- 数据库相关架包开始-->
  6. <dependency>
  7. <groupId>org.mybatis.spring.boot </groupId>
  8. <artifactId>mybatis-spring-boot-starter </artifactId>
  9. <version>2.1.0 </version>
  10. </dependency>
  11. <dependency>
  12. <groupId>mysql </groupId>
  13. <artifactId>mysql-connector-java </artifactId>
  14. <version>5.1.6 </version>
  15. </dependency>
  16. <dependency>
  17. <groupId>com.alibaba </groupId>
  18. <artifactId>druid </artifactId>
  19. <version>1.1.10 </version>
  20. </dependency>
  21. <!-- 数据库相关架包结束-->

配置yml


  
  1. server:
  2. port: 8093
  3. servlet:
  4. context-path: /
  5. spring:
  6. datasource:
  7. type: com.alibaba.druid.pool.DruidDataSource
  8. driver-class-name: com.mysql.jdbc.Driver
  9. url: jdbc:mysql://localhost:3306/study?characterEncoding=utf-8
  10. username: root
  11. password: dscDING1020
  12. primary:
  13. initial-size: 5
  14. max-idle: 10
  15. max-wait: 10000
  16. min-idle: 5
  17. test-on-borrow: false
  18. test-while-idle: true
  19. time-between-eviction-runs-millis: 18800
  20. validation-query: SELECT 1
  21. #mybatis-plush配置
  22. mybatis:
  23. typeAliasesPackage: com.dsc.**.**.entity
  24. mapperLocations: classpath:/mapping/*.xml
  25. configuration:
  26. log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  27. map-underscore-to-camel-case: true #自动开启驼峰规则映射

存放mapper和xml地方


转载:https://blog.csdn.net/qq_26171035/article/details/104417885
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场