最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MyBatis實(shí)現(xiàn)CRUD的示例代碼

 更新時(shí)間:2024年12月08日 09:57:30   作者:耀耀_很無(wú)聊  
本文主要介紹了MyBatis實(shí)現(xiàn)CRUD的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

準(zhǔn)備工作

創(chuàng)建module(Maven的普通Java模塊):mybatis-002-crud

pom.xml

  • 打包方式j(luò)ar
  • 依賴(lài):
    • mybatis依賴(lài)
    • mysql驅(qū)動(dòng)依賴(lài)
    • junit依賴(lài)
    • logback依賴(lài)
  • mybatis-config.xml放在類(lèi)的根路徑下
  • CarMapper.xml放在類(lèi)的根路徑下
  • logback.xml放在類(lèi)的根路徑下
  • 提供com.study.mybatis.utils.SqlSessionUtil工具類(lèi)
  • 創(chuàng)建測(cè)試用例:com.study.mybatis.CarMapperTest

1 insert(Create)

分析以下SQL映射文件中SQL語(yǔ)句存在的問(wèn)題

<?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先隨便寫(xiě)-->
<mapper namespace="car">
    <insert id="insertCar">
        insert into t_car(car_num, brand, guide_price, produce_time, car_type) values ('103', '奔馳E300L', 50.3, '2022-01-01', '燃油車(chē)')
    </insert>
</mapper>

存在的問(wèn)題是:SQL語(yǔ)句中的值不應(yīng)該寫(xiě)死,值應(yīng)該是用戶(hù)提供的。之前的JDBC代碼是這樣寫(xiě)的:

// JDBC中使用 ? 作為占位符。那么MyBatis中會(huì)使用什么作為占位符呢?
String sql = "insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(?,?,?,?,?)";
// ......
// 給 ? 傳值。那么MyBatis中應(yīng)該怎么傳值呢?
ps.setString(1,"103");
ps.setString(2,"奔馳E300L");
ps.setDouble(3,50.3);
ps.setString(4,"2022-01-01");
ps.setString(5,"燃油車(chē)");

在MyBatis中可以這樣做:
在Java程序中,將數(shù)據(jù)放到Map集合中在sql語(yǔ)句中使用 #{map集合的key} 來(lái)完成傳值,#{} 等同于JDBC中的 ? ,#{}就是占位符Java程序這樣寫(xiě):

package com.study.mybatis;

import com.study.mybatis.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * 測(cè)試MyBatis的CRUD
 * @author sqnugy
 * @version 1.0
 * @since 1.0
 */
public class CarMapperTest {
    @Test
    public void testInsertCar(){
        // 準(zhǔn)備數(shù)據(jù)
        Map<String, Object> map = new HashMap<>();
        map.put("k1", "103");
        map.put("k2", "奔馳E300L");
        map.put("k3", 50.3);
        map.put("k4", "2020-10-01");
        map.put("k5", "燃油車(chē)");
        // 獲取SqlSession對(duì)象
        SqlSession sqlSession = SqlSessionUtil.openSession();
        // 執(zhí)行SQL語(yǔ)句(使用map集合給sql語(yǔ)句傳遞數(shù)據(jù))
        int count = sqlSession.insert("insertCar", map);
        System.out.println("插入了幾條記錄:" + count);
    }
}

SQL語(yǔ)句這樣寫(xiě):

<?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先隨便寫(xiě)-->
<mapper namespace="car">
    <insert id="insertCar">
        insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{k1},#{k2},#{k3},#{k4},#{k5})
    </insert>
</mapper>

**#{} 的里面必須填寫(xiě)map集合的key,不能隨便寫(xiě)。**運(yùn)行測(cè)試程序,查看數(shù)據(jù)庫(kù):

如果#{}里寫(xiě)的是map集合中不存在的key會(huì)有什么問(wèn)題?

<?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">

<mapper namespace="car">
    <insert id="insertCar">
        insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{kk},#{k2},#{k3},#{k4},#{k5})
    </insert>
</mapper>

運(yùn)行程序:

通過(guò)測(cè)試,看到程序并沒(méi)有報(bào)錯(cuò)。正常執(zhí)行。不過(guò) #{kk} 的寫(xiě)法導(dǎo)致無(wú)法獲取到map集合中的數(shù)據(jù),最終導(dǎo)致數(shù)據(jù)庫(kù)表car_num插入了NULL。
在以上sql語(yǔ)句中,可以看到#{k1} #{k2} #{k3} #{k4} #{k5}的可讀性太差,為了增強(qiáng)可讀性,我們可以將Java程序做如下修改:

Map<String, Object> map = new HashMap<>();
// 讓key的可讀性增強(qiáng)
map.put("carNum", "103");
map.put("brand", "奔馳E300L");
map.put("guidePrice", 50.3);
map.put("produceTime", "2020-10-01");
map.put("carType", "燃油車(chē)");

SQL語(yǔ)句做如下修改,這樣可以增強(qiáng)程序的可讀性:

<?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">
<mapper namespace="car">
    <insert id="insertCar">
        insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType})
    </insert>
</mapper>

運(yùn)行程序,查看數(shù)據(jù)庫(kù)表:

使用Map集合可以傳參,那使用pojo(簡(jiǎn)單普通的java對(duì)象)可以完成傳參嗎?測(cè)試一下:

  • 第一步:定義一個(gè)pojo類(lèi)Car,提供相關(guān)屬性。
package com.study.mybatis.pojo;

/**
 * POJOs,簡(jiǎn)單普通的Java對(duì)象。封裝數(shù)據(jù)用的。
 * @author sqnugy
 * @version 1.0
 * @since 1.0
 */
public class Car {
    private Long id;
    private String carNum;
    private String brand;
    private Double guidePrice;
    private String produceTime;
    private String carType;

    @Override
    public String toString() {
        return "Car{" +
                "id=" + id +
                ", carNum='" + carNum + '\'' +
                ", brand='" + brand + '\'' +
                ", guidePrice=" + guidePrice +
                ", produceTime='" + produceTime + '\'' +
                ", carType='" + carType + '\'' +
                '}';
    }

    public Car() {
    }

    public Car(Long id, String carNum, String brand, Double guidePrice, String produceTime, String carType) {
        this.id = id;
        this.carNum = carNum;
        this.brand = brand;
        this.guidePrice = guidePrice;
        this.produceTime = produceTime;
        this.carType = carType;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCarNum() {
        return carNum;
    }

    public void setCarNum(String carNum) {
        this.carNum = carNum;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public Double getGuidePrice() {
        return guidePrice;
    }

    public void setGuidePrice(Double guidePrice) {
        this.guidePrice = guidePrice;
    }

    public String getProduceTime() {
        return produceTime;
    }

    public void setProduceTime(String produceTime) {
        this.produceTime = produceTime;
    }

    public String getCarType() {
        return carType;
    }

    public void setCarType(String carType) {
        this.carType = carType;
    }
}
  • 第二步:Java程序
@Test
public void testInsertCarByPOJO(){
    // 創(chuàng)建POJO,封裝數(shù)據(jù)
    Car car = new Car();
    car.setCarNum("103");
    car.setBrand("奔馳C200");
    car.setGuidePrice(33.23);
    car.setProduceTime("2020-10-11");
    car.setCarType("燃油車(chē)");
    // 獲取SqlSession對(duì)象
    SqlSession sqlSession = SqlSessionUtil.openSession();
    // 執(zhí)行SQL,傳數(shù)據(jù)
    int count = sqlSession.insert("insertCarByPOJO", car);
    System.out.println("插入了幾條記錄" + count);
}
  • 第三步:SQL語(yǔ)句
<insert id="insertCarByPOJO">
  <!--#{} 里寫(xiě)的是POJO的屬性名-->
  insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType})
</insert>
  • 運(yùn)行程序,查看數(shù)據(jù)庫(kù)表:

#{} 里寫(xiě)的是POJO的屬性名,如果寫(xiě)成其他的會(huì)有問(wèn)題嗎?

<insert id="insertCarByPOJO">
  insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{a},#{brand},#{guidePrice},#{produceTime},#{carType})
</insert>

運(yùn)行程序,出現(xiàn)了以下異常:

錯(cuò)誤信息中描述:在Car類(lèi)中沒(méi)有找到a屬性的getter方法。

修改POJO類(lèi)Car的代碼,只將getCarNum()方法名修改為getA(),其他代碼不變,如下:

再運(yùn)行程序,查看數(shù)據(jù)庫(kù)表中數(shù)據(jù):

經(jīng)過(guò)測(cè)試得出結(jié)論:

如果采用map集合傳參#{} 里寫(xiě)的是map集合的key,如果key不存在不會(huì)報(bào)錯(cuò),數(shù)據(jù)庫(kù)表中會(huì)插入NULL。

如果采用POJO傳參,#{} 里寫(xiě)的是get方法的方法名去掉get之后將剩下的單詞首字母變小寫(xiě)(例如:getAge對(duì)應(yīng)的是#{age},getUserName對(duì)應(yīng)的是#{userName}),如果這樣的get方法不存在會(huì)報(bào)錯(cuò)。

注意:其實(shí)傳參數(shù)的時(shí)候有一個(gè)屬性parameterType,這個(gè)屬性用來(lái)指定傳參的數(shù)據(jù)類(lèi)型,不過(guò)這個(gè)屬性是可以省略的

<insert id="insertCar" parameterType="java.util.Map">
  insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType})
</insert>

<insert id="insertCarByPOJO" parameterType="com.study.mybatis.pojo.Car">
  insert into t_car(car_num,brand,guide_price,produce_time,car_type) values(#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType})
</insert>

2 delete(Delete)

需求:根據(jù)car_num進(jìn)行刪除。
SQL語(yǔ)句這樣寫(xiě):

<delete id="deleteByCarNum">
  delete from t_car where car_num = #{SuiBianXie}
</delete>

Java程序這樣寫(xiě):

@Test
public void testDeleteByCarNum(){
    // 獲取SqlSession對(duì)象
    SqlSession sqlSession = SqlSessionUtil.openSession();
    // 執(zhí)行SQL語(yǔ)句
    int count = sqlSession.delete("deleteByCarNum", "102");
    System.out.println("刪除了幾條記錄:" + count);
}

運(yùn)行結(jié)果:

注意:當(dāng)占位符只有一個(gè)的時(shí)候,${} 里面的內(nèi)容可以隨便寫(xiě)。

3 update(Update)

需求:修改id=34的Car信息,car_num102,brand比亞迪漢guide_price30.23,produce_time2018-09-10car_type電車(chē)修改前:

SQL語(yǔ)句如下:

<update id="updateCarByPOJO">
  update t_car set 
    car_num = #{carNum}, brand = #{brand}, 
    guide_price = #{guidePrice}, produce_time = #{produceTime}, 
    car_type = #{carType} 
  where id = #{id}
</update>

Java代碼如下:

    @Test
    public void testUpdateCarByPOJO(){
        // 準(zhǔn)備數(shù)據(jù)
        Car car = new Car();
        car.setId(34L);
        car.setCarNum("102");
        car.setBrand("比亞迪漢");
        car.setGuidePrice(30.23);
        car.setProduceTime("2018-09-10");
        car.setCarType("電車(chē)");
        // 獲取SqlSession對(duì)象
        SqlSession sqlSession = SqlSessionUtil.openSession();
        // 執(zhí)行SQL語(yǔ)句
        int count = sqlSession.update("updateCarByPOJO", car);
        System.out.println("更新了幾條記錄:" + count);
    }

運(yùn)行結(jié)果:

0670B92C-E654-49a7-839C-814850A4D79A.png

當(dāng)然了,如果使用map傳數(shù)據(jù)也是可以的。

4 select(Retrieve)

select語(yǔ)句和其它語(yǔ)句不同的是:查詢(xún)會(huì)有一個(gè)結(jié)果集。來(lái)看mybatis是怎么處理結(jié)果集的?。。?/p>

查詢(xún)一條數(shù)據(jù)

需求:查詢(xún)id為1的Car信息
SQL語(yǔ)句如下:

<select id="selectCarById">
  select * from t_car where id = #{id}
</select>

Java程序如下:

@Test
public void testSelectCarById(){
    // 獲取SqlSession對(duì)象
    SqlSession sqlSession = SqlSessionUtil.openSession();
    // 執(zhí)行SQL語(yǔ)句
    Object car = sqlSession.selectOne("selectCarById", 1);
    System.out.println(car);
}

運(yùn)行結(jié)果如下:

### Error querying database.  Cause: org.apache.ibatis.executor.ExecutorException: 
    A query was run and no Result Maps were found for the Mapped Statement 'car.selectCarById'.  【翻譯】:對(duì)于一個(gè)查詢(xún)語(yǔ)句來(lái)說(shuō),沒(méi)有找到查詢(xún)的結(jié)果映射。
    It's likely that neither a Result Type nor a Result Map was specified.                         【翻譯】:很可能既沒(méi)有指定結(jié)果類(lèi)型,也沒(méi)有指定結(jié)果映射。

以上的異常大致的意思是:對(duì)于一個(gè)查詢(xún)語(yǔ)句來(lái)說(shuō),你需要指定它的“結(jié)果類(lèi)型”或者“結(jié)果映射”。

所以說(shuō),你想讓mybatis查詢(xún)之后返回一個(gè)Java對(duì)象的話(huà),至少你要告訴mybatis返回一個(gè)什么類(lèi)型的Java對(duì)象,可以在<select>標(biāo)簽中添加resultType屬性,用來(lái)指定查詢(xún)要轉(zhuǎn)換類(lèi)型:

<select id="selectCarById" resultType="com.study.mybatis.pojo.Car">
  select * from t_car where id = #{id}
</select>

運(yùn)行結(jié)果:

運(yùn)行后之前的異常不再出現(xiàn)了,這說(shuō)明添加了resultType屬性之后,解決了之前的異常,可以看出resultType是不能省略的。

仔細(xì)觀(guān)察控制臺(tái)的日志信息,不難看出,結(jié)果查詢(xún)出了一條。并且每個(gè)字段都查詢(xún)到值了:Row: 1, 100, 寶馬520Li, 41.00, 2022-09-01, 燃油車(chē)

但是奇怪的是返回的Car對(duì)象,只有id和brand兩個(gè)屬性有值,其它屬性的值都是null,這是為什么呢?我們來(lái)觀(guān)察一下查詢(xún)結(jié)果列名和Car類(lèi)的屬性

名是否能一一對(duì)應(yīng):

查詢(xún)結(jié)果集的列名:id, car_num, brand, guide_price, produce_time, car_type

Car類(lèi)的屬性名:id, carNum, brand, guidePrice, produceTime, carType

通過(guò)觀(guān)察發(fā)現(xiàn):只有id和brand是一致的,其他字段名和屬性名對(duì)應(yīng)不上,這是不是導(dǎo)致null的原因呢?我們嘗試在sql語(yǔ)句中使用as關(guān)鍵字來(lái)給查

詢(xún)結(jié)果列名起別名試試:

<select id="selectCarById" resultType="com.study.mybatis.pojo.Car">
  select 
    id, car_num as carNum, brand, guide_price as guidePrice, produce_time as produceTime, car_type as carType 
  from 
    t_car 
  where 
    id = #{id}
</select>

運(yùn)行結(jié)果如下:

在這里插入圖片描述

通過(guò)測(cè)試得知,如果當(dāng)查詢(xún)結(jié)果的字段名和java類(lèi)的屬性名對(duì)應(yīng)不上的話(huà),可以采用as關(guān)鍵字起別名,當(dāng)然還有其它解決方案,我們后面再看。

查詢(xún)多條數(shù)據(jù)

需求:查詢(xún)所有的Car信息。

SQL語(yǔ)句如下:

<!--雖然結(jié)果是List集合,但是resultType屬性需要指定的是List集合中元素的類(lèi)型。-->
<select id="selectCarAll" resultType="com.study.mybatis.pojo.Car">
  <!--記得使用as起別名,讓查詢(xún)結(jié)果的字段名和java類(lèi)的屬性名對(duì)應(yīng)上。-->
  select
    id, car_num as carNum, brand, guide_price as guidePrice, produce_time as produceTime, car_type as carType
  from
    t_car
</select>

Java代碼如下:

@Test
public void testSelectCarAll(){
    // 獲取SqlSession對(duì)象
    SqlSession sqlSession = SqlSessionUtil.openSession();
    // 執(zhí)行SQL語(yǔ)句
    List<Object> cars = sqlSession.selectList("selectCarAll");
    // 輸出結(jié)果
    cars.forEach(car -> System.out.println(car));
}

運(yùn)行結(jié)果如下:

5 關(guān)于SQL Mapper的namespace

在SQL Mapper配置文件中<mapper>標(biāo)簽的namespace屬性可以翻譯為命名空間,這個(gè)命名空間主要是為了防止sqlId沖突的。
創(chuàng)建CarMapper2.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">

<mapper namespace="car2">
    <select id="selectCarAll" resultType="com.study.mybatis.pojo.Car">
        select
            id, car_num as carNum, brand, guide_price as guidePrice, produce_time as produceTime, car_type as carType
        from
            t_car
    </select>
</mapper>

不難看出,CarMapper.xmlCarMapper2.xml文件中都有 id="selectCarAll"CarMapper2.xml配置到mybatis-config.xml文件中。

<mappers>
  <mapper resource="CarMapper.xml"/>
  <mapper resource="CarMapper2.xml"/>
</mappers>

編寫(xiě)Java代碼如下:

@Test
public void testNamespace(){
    // 獲取SqlSession對(duì)象
    SqlSession sqlSession = SqlSessionUtil.openSession();
    // 執(zhí)行SQL語(yǔ)句
    List<Object> cars = sqlSession.selectList("selectCarAll");
    // 輸出結(jié)果
    cars.forEach(car -> System.out.println(car));
}

運(yùn)行結(jié)果如下:

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IllegalArgumentException: 
  selectCarAll is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries) 
  【翻譯】selectCarAll在Mapped Statements集合中不明確(請(qǐng)嘗試使用包含名稱(chēng)空間的全名,或重命名其中一個(gè)條目)
  【大致意思是】selectCarAll重名了,你要么在selectCarAll前添加一個(gè)名稱(chēng)空間,要有你改個(gè)其它名字。

Java代碼修改如下:

@Test
public void testNamespace(){
    // 獲取SqlSession對(duì)象
    SqlSession sqlSession = SqlSessionUtil.openSession();
    // 執(zhí)行SQL語(yǔ)句
    //List<Object> cars = sqlSession.selectList("car.selectCarAll");
    List<Object> cars = sqlSession.selectList("car2.selectCarAll");
    // 輸出結(jié)果
    cars.forEach(car -> System.out.println(car));
}

運(yùn)行結(jié)果如下:

到此這篇關(guān)于MyBatis實(shí)現(xiàn)CRUD的示例代碼的文章就介紹到這了,更多相關(guān)MyBatis實(shí)現(xiàn)CRUD內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • SpringBoot 自定義+動(dòng)態(tài)切換數(shù)據(jù)源教程

    SpringBoot 自定義+動(dòng)態(tài)切換數(shù)據(jù)源教程

    這篇文章主要介紹了SpringBoot 自定義+動(dòng)態(tài)切換數(shù)據(jù)源教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • SpringCloudGateway路由失效問(wèn)題

    SpringCloudGateway路由失效問(wèn)題

    本文主要分析了SpringCloudGateway整合nacos時(shí)路由失效的問(wèn)題,作者通過(guò)斷點(diǎn)跟蹤發(fā)現(xiàn)在RouteToRequestUrlFilter類(lèi)中報(bào)錯(cuò),原因是在讀取配置文件的時(shí)候,沒(méi)有解析到對(duì)應(yīng)的host主機(jī),進(jìn)一步發(fā)現(xiàn)這里包含了一段正則表達(dá)式驗(yàn)證,驗(yàn)證配置的服務(wù)名稱(chēng)是否合法
    2024-10-10
  • Java實(shí)現(xiàn)圖片轉(zhuǎn)換PDF文件的示例代碼

    Java實(shí)現(xiàn)圖片轉(zhuǎn)換PDF文件的示例代碼

    這篇文章主要介紹了Java實(shí)現(xiàn)圖片轉(zhuǎn)換PDF文件的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • java使用ZipInputStream實(shí)現(xiàn)讀取和寫(xiě)入zip文件

    java使用ZipInputStream實(shí)現(xiàn)讀取和寫(xiě)入zip文件

    zip文檔可以以壓縮格式存儲(chǔ)一個(gè)或多個(gè)文件,本文主要為大家詳細(xì)介紹了java如何使用ZipInputStream讀取Zip文檔與寫(xiě)入,需要的小伙伴可以參考下
    2023-11-11
  • Java實(shí)現(xiàn)瀏覽器端大文件分片上傳

    Java實(shí)現(xiàn)瀏覽器端大文件分片上傳

    本文主要介紹了Java實(shí)現(xiàn)瀏覽器端大文件分片上傳,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • MyBatis一次執(zhí)行多條SQL語(yǔ)句的操作

    MyBatis一次執(zhí)行多條SQL語(yǔ)句的操作

    這篇文章主要介紹了MyBatis一次執(zhí)行多條SQL語(yǔ)句的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-12-12
  • 在IntelliJ IDEA中創(chuàng)建和運(yùn)行java/scala/spark程序的方法

    在IntelliJ IDEA中創(chuàng)建和運(yùn)行java/scala/spark程序的方法

    這篇文章主要介紹了在IntelliJ IDEA中創(chuàng)建和運(yùn)行java/scala/spark程序的教程,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Java 數(shù)組(Array)存儲(chǔ)數(shù)據(jù)的“排排坐”(最新推薦)

    Java 數(shù)組(Array)存儲(chǔ)數(shù)據(jù)的“排排坐”(最新推薦)

    這篇文章主要介紹了Java 數(shù)組(Array)存儲(chǔ)數(shù)據(jù)的“排排坐”(最新推薦),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧
    2025-05-05
  • 深入理解JAVA基礎(chǔ)類(lèi)庫(kù)中對(duì)象Object類(lèi)

    深入理解JAVA基礎(chǔ)類(lèi)庫(kù)中對(duì)象Object類(lèi)

    Object類(lèi)是一個(gè)特殊的類(lèi),是所有類(lèi)的父類(lèi),如果一個(gè)類(lèi)沒(méi)有用extends明確指出繼承于某個(gè)類(lèi),那么它默認(rèn)繼承Object類(lèi)。這里主要總結(jié)Object類(lèi)中的兩個(gè):toString()與equals()方法
    2021-09-09
  • Java中的線(xiàn)程池ThreadPoolExecutor解析

    Java中的線(xiàn)程池ThreadPoolExecutor解析

    這篇文章主要介紹了Java中的線(xiàn)程池ThreadPoolExecutor解析,線(xiàn)程池,thread pool,是一種線(xiàn)程使用模式,線(xiàn)程池維護(hù)著多個(gè)線(xiàn)程,等待著監(jiān)督管理者分配可并發(fā)執(zhí)行的任務(wù),需要的朋友可以參考下
    2023-11-11

最新評(píng)論

南皮县| 札达县| 比如县| 武安市| 罗山县| 克什克腾旗| 九江县| 霍林郭勒市| 霞浦县| 莱阳市| 明水县| 藁城市| 西畴县| 祁阳县| 始兴县| 新乡市| 奉新县| 宁陕县| 纳雍县| 西盟| 怀安县| 民县| 通河县| 凤翔县| 广灵县| 鄂托克前旗| 苗栗市| 东安县| 云阳县| 吴旗县| 千阳县| 米脂县| 梁平县| 中牟县| 孙吴县| 神池县| 游戏| 天津市| 双江| 绵竹市| 自贡市|