使用IDEA搭建MyBatis環(huán)境詳細(xì)過程
創(chuàng)建一個(gè)項(xiàng)目

這里根據(jù)需求自己選擇

在pom.xml中導(dǎo)入mybatis的核心jar包
Mybatis 源碼下載
https://github.com/mybatis/mybatis-3/releases

在resources下創(chuàng)建一個(gè)mybatis-config.xml文件寫入mybatis框架的核心配置文件
<?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>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="" />
<property name="url" value="" />
<property name="username" value="" />
<property name="password" value=""/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper>
<!-- 配置sql映射文件 -->
resource="com/sxt/mybatisDemo/mapper/UserMapper.xml"/>
</mappers>
</configuration>

這個(gè)配置可以有多個(gè),如果有服務(wù)器的話可以寫服務(wù)器上的數(shù)據(jù)庫信息

創(chuàng)建mapper,然后在mybatis-config.xml中配置sql映射文件

這里需要注意包的路徑,在這里就可以寫我們的sql語句了

以上就是使用IDEA搭建MyBatis環(huán)境的詳細(xì)內(nèi)容,更多關(guān)于IDEA搭建MyBatis環(huán)境的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
SpringMVC 通過commons-fileupload實(shí)現(xiàn)文件上傳功能
這篇文章主要介紹了SpringMVC 通過commons-fileupload實(shí)現(xiàn)文件上傳,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02
SpringBoot Actuator監(jiān)控的項(xiàng)目實(shí)踐
本文主要結(jié)合 Spring Boot Actuator,跟大家一起分享微服務(wù)Spring Boot Actuator 的常見用法,方便我們?cè)谌粘V袑?duì)我們的微服務(wù)進(jìn)行監(jiān)控治理,感興趣的可以了解一下2024-01-01
@Slf4j?如何實(shí)現(xiàn)日志輸入到外部文件
這篇文章主要介紹了@Slf4j?如何實(shí)現(xiàn)日志輸入到外部文件,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-12-12
詳解Spring 基于 Aspect 注解的增強(qiáng)實(shí)現(xiàn)
本篇文章主要介紹了詳解Spring 基于 Aspect 注解的增強(qiáng)實(shí)現(xiàn),非常具有實(shí)用價(jià)值,需要的朋友可以參考下2017-04-04

