SpringBoot多模块项目MybatisPlus配置

项目目录

主模块配置 

配置类

@Configuration
@EnableTransactionManagement
@MapperScan("com.sms.**.mapper")
public class MybatisPlugConfig {@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));return mybatisPlusInterceptor;}/*** fix : No MyBatis mapper was found in '[xx.mapper]' package. Please check your configuration*/@Mapperpublic interface NoWarnMapper {}
}

启动类

@ComponentScan("com.sms.*")
@SpringBootApplication
@Controller
public class SmsAdminApplication {public static void main(String[] args) {SpringApplication.run(SmsAdminApplication.class, args);}@GetMapping("/message")public String message() {return "message";}
}

yml

# Spring配置
spring:jackson:#参数意义:#JsonInclude.Include.ALWAYS              默认#JsonInclude.Include.NON_DEFAULT     属性为默认值不序列化#JsonInclude.Include.NON_EMPTY         属性为 空(””) 或者为 NULL 都不序列化#JsonInclude.Include.NON_NULL           属性为NULL   不序列化default-property-inclusion: NON_NULLdate-format: yyyy-MM-dd HH:mm:sstime-zone: Asia/Shanghaiserialization:WRITE_DATES_AS_TIMESTAMPS: falseFAIL_ON_EMPTY_BEANS: falseprofiles:active: druidmvc:path match:matching-strategy: ant_path_matcherthymeleaf:mode: HTML5suffix: .htmlencoding: UTF-8cache: false# 服务模块devtools:restart:# 热部署开关enabled: trueknife4j:enable: truelogging:level:com.sms.admin: debugfile:name: "./logs/sms-admin.log"logback:rollingpolicy:max-history: 30max-file-size: 50MBtotal-size-cap: 5GBmybatis-plus:mapper-locations: classpath*:com/sms/**/mapper/xml/*.xml#实体扫描,多个package用逗号或者分号分隔typeAliasesPackage: com.sms.**.entity# 以下配置均有默认值,可以不设置global-config:#刷新mapper 调试神器refresh: truedb-config:id-type: auto#驼峰下划线转换tableUnderline: true#数据库大写下划线转换capital-mode: truewhere-strategy: not_emptybanner: falseconfiguration:# 是否开启自动驼峰命名规则映射:从数据库列名到Java属性驼峰命名的类似映射map-underscore-to-camel-case: true#二级缓存cache-enabled: false#延时加载的开关lazyLoadingEnabled: trueaggressiveLazyLoading: true#开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性multipleResultSetsEnabled: true#关闭sql打印
#    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpllog-impl: org.apache.ibatis.logging.stdout.StdOutImpl

pom

根目录

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.sms</groupId><artifactId>sms</artifactId><version>0.0.1</version><name>···</name><description>···</description><properties><simulationMasterStation.version>0.0.1</simulationMasterStation.version><java.version>11</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.7.6</spring-boot.version></properties><dependencyManagement><dependencies><!-- 主模块--><dependency><groupId>com.sms</groupId><artifactId>sms-admin</artifactId><version>${simulationMasterStation.version}</version></dependency><!-- 子模块--><dependency><groupId>com.sms</groupId><artifactId>···</artifactId><version>${simulationMasterStation.version}</version></dependency></dependencies></dependencyManagement><modules><module>sms-admin</module><module>···</module></modules><packaging>pom</packaging><dependencies></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>${java.version}</source><target>${java.version}</target><encoding>${project.build.sourceEncoding}</encoding></configuration></plugin></plugins></build>
</project>

 主模块

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><groupId>com.sms</groupId><artifactId>sms</artifactId><version>0.0.1</version></parent><modelVersion>4.0.0</modelVersion><name>sms-admin</name><description>sms-admin</description><packaging>jar</packaging><artifactId>sms-admin</artifactId><properties><java.version>11</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.7.6</spring-boot.version></properties><dependencies><!-- 子模块--><dependency><groupId>···</groupId><artifactId>···</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><mainClass>com.sms.admin.SmsAdminApplication</mainClass></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>3.1.0</version><configuration><failOnMissingWebXml>false</failOnMissingWebXml><warName>${project.artifactId}</warName></configuration></plugin></plugins><finalName>${project.artifactId}</finalName></build>
</project>

后记

classpath和classpath*的区别

classpath:只会到你的class路径中查找找文件。

classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找。

注意: 用classpath*:需要遍历所有的classpath,所以加载速度是很慢的;因此,在规划的时候,应该尽可能规划好资源文件所在的路径,尽量避免使用classpath*。  

mapper-locations配置方式

方式一:放在Mapper目录下

yml

mybatis-plus:mapper-locations: classpath*:com/sms/**/mapper/xml/*.xml

pom

    <build><resources><!-- 扫描src/main/java下所有xx.xml文件 --><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource></resources></build>

方式二:放在resource下

yml

# mybatis-plus相关配置
mybatis-plus:# xml扫描,多个目录用逗号或者分号分隔(告诉 Mapper 所对应的 XML 文件位置)mapper-locations: classpath*:mybatis/*Mapper.xml

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/12238.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

代码随想录算法训练营第二十八天| LeetCode93.复原IP地址 、LeetCode78.子集、LeetCode90.子集II

LeetCode 93. Restore IP Addresses LeetCode 93. 视频讲解&#xff1a;回溯算法如何分割字符串并判断是合法IP&#xff1f;| LeetCode&#xff1a;93.复原IP地址_哔哩哔哩_bilibili 这里返回的数字类型是List<String> 类型&#xff0c;那么可以直接操作String s&#xf…

回复完成 输入框还显示值的问题

回复完成 输入框还显示值的问题 解决代码 先把id 值清空 再构建下这个输入框 $("#details_article_reply_content").val(""); // 清空textareavar editor editormd("article_details_reply", {width: "100%",height: "100%"…

网上有哪些赚钱的方法能一天赚二三十?盘点7个靠谱的搞钱副业和赚钱软件

想在家里躺着就能把钱赚&#xff1f;这不再是遥不可及的梦想&#xff01;随着互联网的飞速发展&#xff0c;网上赚钱的方式层出不穷&#xff0c;总有一款适合你。 今天&#xff0c;就让我们一起揭开这些神秘面纱&#xff0c;看看哪些网上赚钱秘诀能让你轻松实现月入过万&#x…

PPQ模型量化工具

win11&#xff1a;ppq&#xff08;YOLO模型量化&#xff09;环境安装过程记录_windows11 yolox-CSDN博客

js 字符串 replace方法及示例

下面是一些使用JavaScript中字符串 replace 方法的示例代码&#xff0c;这些示例将帮助你理解如何使用此方法进行基本替换以及更高级的替换操作&#xff0c;包括使用正则表达式和函数作为替换值。 基础替换 let originalText "Hello, World!"; let newText origi…

C# OpenCvSharp DNN 黑白老照片上色

C# OpenCvSharp DNN 黑白老照片上色 目录 效果 项目 代码 下载 参考 效果 项目 代码 using OpenCvSharp; using OpenCvSharp.Extensions; using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropS…

工大智信智能听诊器在现代医疗管理中的应用

在现代医疗领域&#xff0c;随着科技的不断进步&#xff0c;智能医疗设备正逐渐成为提升医疗服务质量、优化医疗流程的重要工具。工大智信智能听诊器作为其中的佼佼者&#xff0c;其在医疗管理中的应用日益广泛&#xff0c;以下是其在不同医疗场景中的管理关键词及其应用概述。…

你有没有调用过第三方接口?碰到过哪些坑?

在我们的业务开发中&#xff0c;调用第三方接口已经成为常态&#xff0c;比如对接一些ERP系统、WMS系统、一些数据服务系统等&#xff0c;它极大地扩展了我们应用的功能和服务范围。然而&#xff0c;实际对接过程中&#xff0c;我们往往会在这一环节遇到各种意想不到的问题&…

Oracle 更改数据文件位置的几种常用方式

Oracle 更改数据文件位置的几种常用方式 A.归档模式下 1、offline 表空间&#xff1a;alter tablespace tablespace_name offline&#xff1b; 2、复制数据文件到新的目录&#xff1b; 3、rename 修改表空间&#xff0c;并修改控制文件&#xff1b; 4、online 表空间&#xf…

项目实施方案:多点异地机动车典型系统试验状态可视监控系统

目录 一、需求分析 1.1项目背景 1.2项目概述 二、系统优势 2.1兼容性能力强 2.2接入协议多样 2.3并发能力强 2.3.1 单平台参数 2.3.2 多平台性能参数 2.4 系统稳定性 三、建设目标 3.1安全性 3.2可扩展性 3.3易用性 3.4兼容性 3.5 响应能力 四、系统整体解决方…

单区域OSPF实验

实验目的&#xff1a; 理解OSPF的基本概念。掌握单曲于OSPF的配置掌握OSPF邻居状态的解读掌握通过Cost控制OSPF选路的方法掌握OSPF认证的配置方法 一、基础配置&#xff1a; 搭建实验拓扑图&#xff1b; 配置路由器接口的IP地址以及配置环回地址待后续使用 &#xff08;1&a…

MySQL数据分组技术深度解析及实践

在处理大量数据库记录时,数据分组是一种强大的工具,它允许我们按照特定列的值将数据划分为逻辑上的集合,进而对每个集合执行聚合操作,如计数、求和或平均值等。MySQL中的​​GROUP BY​​​子句正是实现这一功能的关键所在。本文将详细介绍​​GROUP BY​​的使用方法,结合…

文献速递:深度学习医学影像心脏疾病检测与诊断--基于深度学习的低剂量SPECT心肌灌注图像去噪:定量评估与临床表现

Title 题目 Deep learning–based denoising of low‑dose SPECT myocardialperfusion images: quantitative assessment and clinical performance 基于深度学习的低剂量SPECT心肌灌注图像去噪&#xff1a;定量评估与临床表现 01 文献速递介绍 单光子发射计算机断层扫描&a…

SMB攻击利用之-通过psexec发送命令流量数据包分析

SMB协议作为windows环境下最为常见的一种协议,在历史上出现过无数的通过SMB协议进行网络攻击利用的案例,包括针对SMB协议本身以及通过SMB协议实施网络攻击。 本文将介绍一种通过SMB协议的常见利用方式,即通过psexec工具控制远程的主机,作为我的专栏《SMB攻击流量数据包分析…

Spring的IOC和AOP机制?

我们是在使用Spring框架的过程中&#xff0c;其实就是为了使用IOC&#xff0c;依赖注入&#xff0c;和AOP&#xff0c;面向切面编程&#xff0c;这两个是Spring的灵魂。 主要用到的设计模式有工厂模式和代理模式。 IOC就是典型的工厂模式&#xff0c;通过sessionfactory去注入…

华为设备IPsecVPN配置记录

IPsec加密和验证算法所使用的密钥可以手工配置&#xff0c;也可以通过因特网密钥交换IKE协议动态协商&#xff0c;IKE协议建立在internet安全联盟和密钥管理协议ISAKMP框架之上&#xff0c;采用DH算法在不安全的网络上安全的分发密钥&#xff0c;验证身份&#xff0c;以保证数据…

数据结构与算法-相对排序

问题描述&#xff1a; 给定两个数组&#xff0c;arr1和arr2&#xff0c;arr2中的元素各不相同&#xff0c; 且arr2中的所有元素都出现在arr1中。请对arr1中的元素进行排序&#xff0c; 使arr1中元素的相对顺序和arr2中元素的相对顺序相同&#xff0c; :根绝数组2排序数组1 未…

kong 相关文档

kong 3.4x api 说明 kong 3.4x api 说明 kong 3.4 kong 3.4 修改target的weight curl --request PATCH \--url http://192.168.100.112:8001/upstreams/testcomment-cn/targets/testcomment-cn.cn6.svc.cluster.local%3A80 \--header Content-Type: application/json \--heade…

leetcode刷题指南

本文我将分享给大家一套我自己使用良久并觉得非常高效的 学习论&#xff0c;它可以运用到 Leetcode 上的刷题&#xff0c;也可以 generalize 到生活中涉及到学习以及记忆的方方面面。当然&#xff0c;本文将以 Leetcode 刷题为 case study 去进行讲解。 更具体一点, 我会教大家…

JavaScript的综合案例

案例要求&#xff1a; 实现一个表单验证 1.当输入框失去焦点时&#xff0c;验证输入的内容是否符合要求 2.当点击注册按钮时&#xff0c;判断所有输入框的内容是否都符合要求&#xff0c;如果不符合要求阻止表单提交 简单的页面实现 <!DOCTYPE html> <html lang&…