小議SqlMapConfig.xml配置文件

①、mybatis-3-config.dtd

主要用于mybatis的核心配文件sqlMapConfig.xml的約束
sqlMapConfig.xml代碼如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><!-- 和spring整合后 environments配置將廢除 --><environments default="development"><environment id="development"><!-- 使用jdbc事務管理 --><transactionManager type="JDBC" /><!-- 數據庫連接池 --><dataSource type="POOLED"><property name="driver" value="com.mysql.jdbc.Driver" /><property name="url"value="jdbc:mysql://localhost:3306/mybatis?characterEncoding=utf-8" /><property name="username" value="root" /><property name="password" value="beyond" /></dataSource></environment></environments><!-- Mapper的位置 --><mappers><mapper resource="sqlmap/User.xml"/></mappers></configuration>

在這里插入圖片描述

-//mybatis.org//DTD Config 3.0//EN
配置步驟如下:在這里插入圖片描述在這里插入圖片描述
-//mybatis.org//DTD Config 3.0//EN

在這里插入圖片描述

②、mybatis-3-mapper.dtd

同樣的步驟,找到User.xml
User.xml內容如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- namespace:命名空間,用于隔離sql,還有一個很重要的作用,后面會講 -->
<!-- 
命名空間:user.findUserById
命名空間:order.findUserById 
--><mapper namespace="com.pdsu.mybatis.mapper.UserMapper"><!-- resultType:返回值parameterType:輸入參數 --><!-- 通過ID查詢一個用戶 --><select id="findUserById" parameterType="Integer" resultType="com.pdsu.mybatis.pojo.User">select * from user where id= #{sq}</select><!-- #{} === select * from user where username=     表示占位符?   sq可以隨意替代=== select * from user where username= '思琪'${} === select * from user where username like '%${value}%'  表示字符串拼接  value不可以隨意替代=== select * from user where username like '%琪%' 			sql 模糊語句查詢=== select * from user where username like "%"'琪%'"%" 		sql 模糊語句查詢=== select * from user where username like "%"#{sq}"%" --><!-- 根據用戶名稱模糊查詢用戶列表 --><select id="findUserByUsername" parameterType="String" resultType="com.pdsu.mybatis.pojo.User">select * from user where username like '%${value}%'</select><!-- 添加用戶 --><insert id="insertUser" parameterType="com.pdsu.mybatis.pojo.User"><selectKey keyProperty="id" resultType="Integer" order="AFTER" >select LAST_INSERT_ID()</selectKey>insert into user(username,birthday,address,sex) values (#{username},#{birthday},#{address},#{sex})</insert><!-- 更新用戶 --><update id="updateUserById" parameterType="com.pdsu.mybatis.pojo.User">update user set username = #{username},sex = #{sex},birthday = #{birthday},address = #{address}where id = #{id}</update>	<!-- 刪除用戶 --><delete id="deleteUserById" parameterType="Integer" >delete from user where id = #{sq}</delete></mapper>

找到PUBLIC的內容:

.//mybatis.org//DTD Mapper 3.0//EN

在這里插入圖片描述

最后完成的結果如下:
在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379439.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379439.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379439.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

ffmepg 命令提取音視頻數據

原文件&#xff1a; 1&#xff1a; 原音頻數據提取&#xff08;保留還是mp4的封裝格式的&#xff09;&#xff1a; ffmpeg -i test_1920x1080.mp4 -acodec copy -vn audio.mp4 -vn 就是沒有視頻&#xff0c; -acodec copy 音頻拷貝不進行任何轉碼 原視頻數據提取&#xff0…

Java BigInteger類| modInverse()方法與示例

BigInteger類modInverse()方法 (BigInteger Class modInverse() method) modInverse() method is available in java.math package. modInverse()方法在java.math包中可用。 modInverse() method is used to calculate the mod inverse by using the inverse of (this BigInteg…

【7】jQuery學習——入門jQuery選擇器之過濾選擇器-可見性過濾選擇器

這篇什么都不說&#xff0c;看標題就知道了&#xff0c;很簡單&#xff0c;就2個選擇器&#xff0c;嘿嘿 選擇器描述返回$("Element:hidden")選取所有不可見的元素集合元素$("Element:visible")選取所有可見元素集合元素這篇很簡單吧&#xff0c;就2個&…

Creating an undraggable TitleWindow container in Flex (轉載)

The following examples show how you can create an undraggable TitleWindow container by setting the isPopUp property to false on the TitleWindow instance. <?xml version"1.0" encoding"utf-8"?><!-- http://blog.flexexamples.com/2…

匯編語言-003(LAHF_SAHF 、XCHG、FLAGS、 OFFSET、ALIGN、PTR、LENGTHOF、SIZEOF)

1&#xff1a;LAHF將EFLAGS符號寄存器低8位字節復制到AH&#xff0c;SAHF將AH復制到EFLAGS符號寄存器低8位字節 .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.data saveflags BYTE ?.code main PROClahfmov saveflags ,ahmov ah,saveflagssahfIN…

Mybatis中的核心配置文件SqlMapConfig.xml詳細介紹

一、properties&#xff08;屬性&#xff09; 可以引用java屬性文件中的配置信息如下 jdbc.properties代碼如下&#xff1a; jdbc.drivercom.mysql.jdbc.Driver jdbc.urljdbc:mysql://localhost:3306/mybatis?characterEncodingutf-8 jdbc.usernameroot jdbc.passwordbeyond…

用Kotlin開發您的第一個應用程序| Android與Kotlin

In the previous article, we learned how to setup Kotlin in the android studio? Now moving to journey ahead we are going to develop our first app with Kotlin. It is the basic app, but it will let you know the structure of the program. 在上一篇文章中&#x…

數據結構與算法分析-第一章Java類(02)

編寫一個名為Person的類&#xff0c;它包含分別表示人的名字與年齡的兩個數據域。要求此類包含對其中任何一個數據域進行設置與獲取的方法。還要求包含可進行下列測試的方法&#xff1a; 兩個Person對象是否相等--即是否有相同的名稱與年齡一個人是否比另一個人年長 最后&#…

asp.net對于長篇文章進行分頁

對于文章篇幅比較長的&#xff0c;就必須采用分頁顯示。在.net中對長篇文章分頁一般有2種方法&#xff0c;第一種就是先計算好一頁的文字長度是多少&#xff0c;然后把文章總的長度除設置好的單頁文字長度及可&#xff0c;用這方法可以減少認為進行分頁的繁瑣&#xff0c;但是這…

匯編語言-004(LABEL 、間接尋址、變址操作數、指針使用、TypeDef、LOOP、DWORD變量交換高位低位字)

1&#xff1a; LABEL : 為一個標號定義大小屬性&#xff0c;但不分配內存與下一個變量共用內存&#xff0c;與C中UNION類似 .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCoed:DWORD.data val16 LABEL WORD val32 DWORD 12345678hLongValue LABEL DWORD val1…

(只需挨個復制粘貼命令即可部署)在Centos7下搭建文件服務器(VSFTPD)

觀看北京尚學堂-百戰程序員筆記一、VSFTPD簡介 Linux的組件&#xff08;一款軟件&#xff09;&#xff0c;安裝到Linux后可以通過java代碼&#xff08;FtpClient&#xff09;實現文件的上傳。基于FTP協議。 由于VSFTPD是基于FTP協議&#xff0c;客戶端瀏覽器是需要通過http協議…

POJ 2421 Constructing Roads MST kruskal

最近剛學的并查集所以用kruskal來試試最小生成樹~ kruskal其實用幾句話就能說完~ 1.貪心所有邊的權值,從小到大取值 2.取值時~將邊權非0的兩個頂點~進行并查操作~如果兩個點的祖先不同...邊權加入最小生成樹...并且將兩個點納入同一個集合中 3.判斷是否所有點都在同一個集合中…

c# 聲明類的時候初始化類_使用C#初始化的列表聲明

c# 聲明類的時候初始化類The task is to create/declare a list with an initializer list in C#. 任務是在C&#xff03;中使用初始化列表創建/聲明一個列表 。 C&#xff03;清單 (C# List) A list is used to represent the list of the objects, it is represented as Lis…

編寫程序計算所輸日期是當年的第幾天

/* 1.輸入年月日&#xff0c;編寫程序計算所輸日期是當年的第幾天 *//* 2.已知列車隔日發車&#xff0c;且1/1/2006不發車(無ticket),如果所輸入數據在此日期之后&#xff0c;則輸出有沒有車票&#xff0c;否則僅輸出上一步結果。*/ /* month/date/year is which day of the ye…

匯編語言-005(XCHG、標志位操作、算術操作、比例因子的變址尋址、多個常用運算符運用、大端轉小端、數組操作)

1: 用不超過3條XCHG指令對4個8位寄存器的值重新排序&#xff0c;A,B,C,D調整為D,C,B,A .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.data.code main PROCmov al,Amov bl,Bmov cl,Cmov dl,Dxchg al,dlxchg bl,clINVOKE ExitProcess,0 main ENDP E…

bcd碼二進制轉十進制_二進制編碼的十進制(BCD碼)及其加法

bcd碼二進制轉十進制Prerequisite: Number systems 先決條件&#xff1a; 數字系統 BCD Code (8421 Code): In BCD 8421 code, each decimal digit is represented using a 4-bit binary number. The 4-bit binary numbers have their weights attached as 8, 4, 2, 1 from MS…

SVN服務器部署

一、SVN版本控制器 Subversion就是一款實現版本控制的工具軟件&#xff0c;通常也成為版本控制器&#xff0c;簡稱SVN。 Subversion是Apache軟件基金會組織下的一個項目 SVN基本操作&#xff1a; checkout&#xff08;檢出&#xff09;&#xff1a;將一個服務端創建好的項目…

rtmp流\http流測試地址

測試方式&#xff1a;ffplay rtmp://58.200.131.2:1935/livetv/cctv1 rtmp&#xff1a; CCTV-1綜合:rtmp://58.200.131.2:1935/livetv/cctv1 CCTV-2財經:rtmp://58.200.131.2:1935/livetv/cctv2 CCTV-3綜藝:rtmp://58.200.131.2:1935/livetv/cctv3 CCTV-4中文國際:rtmp://58.2…

LINQ to XML:如何讀寫XCData

using System;using System.Xml.Linq;namespace ConsoleApplication1 {class Program{static void Main(string[] args){//寫入CDATA元素塊var doc new XElement("Test",new XElement("User",new XAttribute("name", "chenxizhang"),…

C#中的結構和類之間的區別

C&#xff03;類和結構 (C# class and structure) In C# and other programming languages, structure and classes are used to define a custom data type, that we can organize according to our need with different types of variables, methods etc. 在C&#xff03;和其…