tnblog
首页
视频
资源
登录

Mybatis的SQL构建7 小小扩展+springboot

3583人阅读 2021/11/16 17:32 总访问:1054137 评论:0 收藏:0 手机
分类: Mybatis高

pom.xml的依赖,我是直接在spring.io官方下的,这样避免依赖冲突

<!--      jdbc-->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-jdbc</artifactId>
      </dependency>
<!--      web-->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
<!--      mybatis-->
      <dependency>
         <groupId>org.mybatis.spring.boot</groupId>
         <artifactId>mybatis-spring-boot-starter</artifactId>
         <version>2.2.0</version>
      </dependency>
<!--      sqlserver数据库-->
      <dependency>
         <groupId>com.microsoft.sqlserver</groupId>
         <artifactId>mssql-jdbc</artifactId>
         <scope>runtime</scope>
      </dependency>
<!--      lombok便于实体的创建-->
      <dependency>
         <groupId>org.projectlombok</groupId>
         <artifactId>lombok</artifactId>
         <optional>true</optional>
      </dependency>

数据库的配置

SQL server:配置代码

spring:
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://localhost:1433;DatabaseName=youdate
    username: youname
    password: youpwd
    maxActive: 20
    initialSize: 1
    maxWait: 60000
    minIdle: 1
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: select 1
    testWhileIdle: true
    testOnBorrow: true
    testOnReturn: true
    poolPreparedStatements: true
    maxOpenPreparedStatements: 20

接口传参的方式



SQL的实现方式

持久层、服务层、测试类

结果

评价
没有个性,不需要签名
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术