zoukankan      html  css  js  c++  java
  • MybatisPlus集成到spring cloud

    1.导包

     <!--mybatisplus的包-->
                <dependency>
                    <groupId>com.baomidou</groupId>
                    <artifactId>mybatis-plus-boot-starter</artifactId>
                    <version>2.2.0</version>
                </dependency>
                <!--连接数据库-->
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.1.6</version>
                </dependency>
    
                <!-- druid连接池的包 -->
                <dependency>
                    <groupId>com.alibaba</groupId>
                    <artifactId>druid</artifactId>
                    <version>1.1.10</version>
                </dependency>

    2.在主配置类上添加标签

    package cn.jiedada;
    
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
    import org.springframework.transaction.annotation.EnableTransactionManagement;
    
    /**
     * @EnableTransactionManagement:开启事务
     */
    @SpringBootApplication
    @EnableEurekaClient
    @EnableTransactionManagement
    @MapperScan(basePackages = "cn.jiedada.hrm.mapper")
    public class SystemManageApplication2010 {
        public static void main(String[] args) {
            new SpringApplicationBuilder(SystemManageApplication2010.class).web(true).run(args);
        }
    
    }

    3.修改yml

    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:1010/eureka/
      instance:
        ip-address: true
        instance-id: systemmanage-server
    server:
      port: 2010
    spring:
      application:
        name: systemmanage-server
      datasource:
        username: root
        password: 123456
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql:///hrm-systemmanage
        type: com.alibaba.druid.pool.DruidDataSource
    mybatis-plus:
      mapper-locations: classpath:cn/itsource/hrm/mapper/*Mapper.xml
      type-aliases-package: cn.jiedada.hrm.domain,cn.jiedada.hrm.query
  • 相关阅读:
    Eclipse 远程调试
    大数据处理方法bloom filter
    sicily 1259 Sum of Consecutive Primes
    sicily 1240. Faulty Odometer
    sicily 1152 简单马周游 深度优先搜索及回溯算法
    sicily 1050 深度优先搜索解题
    sicily 1024 邻接矩阵与深度优先搜索解题
    sicily 1156 二叉树的遍历 前序遍历,递归,集合操作
    sicily 1443 队列基本操作
    sicily 1006 team rankings 枚举解题
  • 原文地址:https://www.cnblogs.com/xiaoruirui/p/11962269.html
Copyright © 2011-2022 走看看