当前位置: 首页 > news >正文

保定公司做网站打开百度搜索网站

保定公司做网站,打开百度搜索网站,企业邮箱怎么查找,软件网站开发团队名称目录 一、依赖变更 1. MybatisPlus依赖 2. pagehelper依赖修改 二、相关配置 1. yml配置 1.1 注释掉原Mybatis配置 1.2 加入MybatisPlus的配置 1.3 注释掉原MybatisConfig.class 三、其他配置及功能实现 1. 自动补全create_time等信息 2. 实现MP分页 3. 实现Mybati…

目录

一、依赖变更

1. MybatisPlus依赖

2. pagehelper依赖修改

二、相关配置

1. yml配置

1.1 注释掉原Mybatis配置

1.2 加入MybatisPlus的配置

1.3 注释掉原MybatisConfig.class

三、其他配置及功能实现

1. 自动补全create_time等信息

2. 实现MP分页

3. 实现MybatisPlus代码生成

3.1 方法一:使用MP自带的代码生成方法

3.2 方法二:修改若依框架的代码生成部分以实现MP代码生成

一、依赖变更

1. MybatisPlus依赖(向ruoyi-common中导入mybatisplus的两个依赖)

<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.2</version>
</dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-extension</artifactId><version>3.5.2</version><scope>compile</scope>
</dependency>

建议使用3.5.1及以上版本,3.4.x版分页有问题

2. pagehelper依赖修改

pagehelper依赖中不引用Mybatis相关依赖(MP依赖中自带Mybatis依赖),这样pagehelper分页依然可用

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><exclusions><exclusion><artifactId>mybatis-spring</artifactId><groupId>org.mybatis</groupId></exclusion><exclusion><artifactId>mybatis</artifactId><groupId>org.mybatis</groupId></exclusion></exclusions>
</dependency>

二、相关配置

1. yml配置

1.1 注释掉原Mybatis配置
# MyBatis配置
#mybatis:
#    # 搜索指定包别名
#    typeAliasesPackage: com.bsd.**.domain
#    # 配置mapper的扫描,找到所有的mapper.xml映射文件
#    mapperLocations: classpath*:mapper/**/*Mapper.xml
#    # 加载全局的配置文件
#    configLocation: classpath:mybatis/mybatis-config.xml
1.2 加入MybatisPlus的配置
mybatis-plus:# Mapper.xml 文件位置 Maven 多模块项目的扫描路径需以 classpath*: 开头mapper-locations: classpath*:mapper/**/*Mapper.xml#  #MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名 实体扫描,多个package用逗号或者分号分隔type-aliases-package: com.bsd.**.domain
#  config-location: classpath:mybatis/mybatis-config.xml#  #通过父类(或实现接口)的方式来限定扫描实体#  typeAliasesSuperType: com.vanhr.user.dao.entity.baseEntity#  #枚举类 扫描路径 如果配置了该属性,会将路径下的枚举类进行注入,让实体类字段能够简单快捷的使用枚举属性#  typeEnumsPackage: com.vanhr.user.dao.enums# 启动时是否检查 MyBatis XML 文件的存在,默认不检查 仅限spring boot 使用checkConfigLocation : true#  #通过该属性可指定 MyBatis 的执行器,MyBatis 的执行器总共有三种:#  # ExecutorType.SIMPLE:该执行器类型不做特殊的事情,为每个语句的执行创建一个新的预处理语句(PreparedStatement)#  # ExecutorType.REUSE:该执行器类型会复用预处理语句(PreparedStatement)
1.3 注释掉原MybatisConfig.class

位置:com/bsd/framework/config/MyBatisConfig.java

建议先别删除,若出现问题还可以退回去使用Mybatis

此时MybatisPlus已经可以正常使用了,下面再记录一下其他常用配置


添加MybatisPlusConfig

package com.mz.framework.config;import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;/*** Mybatis Plus 配置** @author ruoyi*/
@EnableTransactionManagement(proxyTargetClass = true)
@Configuration
public class MybatisPlusConfig
{@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor(){MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();// 分页插件interceptor.addInnerInterceptor(paginationInnerInterceptor());// 乐观锁插件interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());// 阻断插件interceptor.addInnerInterceptor(blockAttackInnerInterceptor());return interceptor;}/*** 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html*/public PaginationInnerInterceptor paginationInnerInterceptor(){PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();// 设置数据库类型为mysqlpaginationInnerInterceptor.setDbType(DbType.MYSQL);// 设置最大单页限制数量,默认 500 条,-1 不受限制paginationInnerInterceptor.setMaxLimit(-1L);return paginationInnerInterceptor;}/*** 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html*/public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor(){return new OptimisticLockerInnerInterceptor();}/*** 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html*/public BlockAttackInnerInterceptor blockAttackInnerInterceptor(){return new BlockAttackInnerInterceptor();}
}

3. 实现MybatisPlus代码生成

修改若依框架的代码生成部分以实现MP代码生成

因为若依的代码生成是使用velocity确定模版,再根据模版来生成代码,所以只要将MP相关代码部分(主要是一些注解和继承接口)添加到velocity模版即可。

Velocity语法教学:Java Velocity模板引擎详解

下面将修改好的vm文件贴出(包括domain、mapper、service、serviceImpl):

domain.java.vm

package ${packageName}.domain;#foreach ($import in $importList)
import ${import};
#end
import com.bsd.common.annotation.Excel;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
#if($table.crud || $table.sub)
import com.bsd.common.core.domain.BaseEntity;
#elseif($table.tree)
import com.bsd.common.core.domain.TreeEntity;
#end

mapper.java.vm

package ${packageName}.mapper;import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import ${packageName}.domain.${ClassName};
#if($table.sub)
import ${packageName}.domain.${subClassName};
#end/*** ${functionName}Mapper接口** @author ${author}* @date ${datetime}*/

service.java.vm

package ${packageName}.service;import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import ${packageName}.domain.${ClassName};/*** ${functionName}Service接口** @author ${author}* @date ${datetime}*/
public interface I${ClassName}Service extends IService<${ClassName}>
{/**

serviceImpl.java.vm

package ${packageName}.service.impl;import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.bsd.common.utils.DateUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#if($table.sub)
import java.util.ArrayList;
import com.bsd.common.utils.StringUtils;

有关MybatisPlus的其他问题,或者上面未说明的问题,均可查看MybatisPlus官网指南:简介 | MyBatis-Plus

http://www.skylitedrivein.com/news/369.html

相关文章:

  • wordpress搭建博客视频教程游戏优化大师官网
  • 美辰网站建设百度搜索引擎优化的推广计划
  • 网站建设app新闻热点事件2024最新
  • 云狄网站建设海南seo
  • 无锡高端网站建设机构百度百科优化
  • 移动网站开发服务seo推广教程
  • 抚顺网络推广北京网站快速排名优化
  • 汉沽网站建设做网站设计哪里有
  • 电商网站建设流程图网店推广
  • 上海网站建设 上海网站制作平台网站开发公司
  • 贵阳网站建设中国突然宣布大消息
  • 玉田县建设局网站湖南长沙最新情况
  • 企业网站设计与制作网站百度收录秒收方法
  • 我的网站现在没有排名_我想问是不是花钱做百度推广就会有排名安卓优化大师老版本
  • 用scala做的网站sem专员
  • 医药企业建设网站需要什么seo百度排名优化
  • 买手表去哪个网站买是正品的郑州高端网站制作
  • 深圳专业网站建设制作价格2021年网络营销考试题及答案
  • php网站开发cms外贸业务推广
  • 安徽省工程建设监理协会网站seo关键词优化的技巧
  • 做名人故居的网站多少钱自己的网站怎么样推广优化
  • 查看网站dns服务器java培训机构
  • 深圳市住房和建设局官网站首页平面设计正规培训机构
  • 电商网站怎么做CSSseo现在还有前景吗
  • 如何做英文网站推广百度上海推广优化公司
  • html5 可以做网站吗建站小程序
  • 做张网站banner多少钱百度知道个人中心
  • 苹果销售网站怎么做的从事网络销售都有哪些平台呢
  • 高安网站制作提高百度搜索排名工具
  • 佛山新网站制作机构网店推广平台有哪些