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

解析MyBatis源碼實現(xiàn)自定義持久層框架

 更新時間:2022年05月28日 11:02:58   作者:第二范式  
這篇文章主要介紹了手撕MyBatis源碼實現(xiàn)自定義持久層框架,涉及到的設(shè)計模式有Builder構(gòu)建者模式、??模式、代理模式,本文通過示例代碼給大家介紹的非常詳細,需要的朋友可以參考下

自定義框架設(shè)計

使用端

提供核?配置?件:

sqlMapConfig.xml : 存放數(shù)據(jù)源信息,引?mapper.xml

Mapper.xml : sql語句的配置?件信息

框架端:

1.讀取配置?件

讀取完成以后以流的形式存在,我們不能將讀取到的配置信息以流的形式存放在內(nèi)存中,不好操作,可以創(chuàng)建JavaBean來存儲

(1)Configuration : 存放數(shù)據(jù)庫基本信息、Map<唯?標識,Mapper>, 唯?標識:namespace + "." + id

(2)MappedStatement:sql語句的id、sql語句、輸?參數(shù)java類型、輸出參數(shù)java類型

2.解析配置?件

創(chuàng)建SqlSessionFactoryBuilder類:

?法:返回值SqlSessionFactory,方法為build()

第?:使?dom4j解析配置?件,將解析出來的內(nèi)容封裝到ConfigurationMappedStatement

第?:創(chuàng)建SqlSessionFactory的實現(xiàn)類DefaultSqlSessionFactory

3.創(chuàng)建SqlSessionFactory

?法:openSession() : 獲取SqlSession接?的實現(xiàn)類實例對象

4.創(chuàng)建SqlSession接?及實現(xiàn)類:主要封裝crud?法

?法:selectList(String mappedStatementId,Object... param):查詢所有

selectOne(String mappedStatementId,Object... param):查詢單個

具體實現(xiàn):封裝JDBC完成對數(shù)據(jù)庫表的查詢操作

涉及到的設(shè)計模式

Builder構(gòu)建者模式、??模式、代理模式

自定義框架實現(xiàn)

這里只做比較繁瑣的查詢單條和查詢多條的實現(xiàn),添加、修改、刪除的參考自行實現(xiàn)。

使用端

創(chuàng)建sqlMapConfig.xml

<configuration>
        <!--數(shù)據(jù)庫配置信息-->
    <dataSource>
        <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
        <property name="jdbcUrl" value="jdbc:mysql:///learning_db"></property>
        <property name="username" value="root"></property>
        <property name="password" value="123456"></property>
    </dataSource>
    <!--存放mapper.xml的全路徑-->
    <mapper resource="UserMapper.xml"></mapper>
</configuration>

mapper.xml

<mapper namespace="com.snf.mapper.UserMapper">
    <!--sql的唯一標識:namespace.id來組成 : mappedStatementId-->
    <select id="findAll" resultType="com.snf.domain.User" >
        select * from user
    </select>
    <!--
        User user = new User()
        user.setId(1);
        user.setUsername("zhangsan")
    -->
    <select id="findByCondition" resultType="com.snf.domain.User" parameterType="com.snf.domain.User">
        select * from user where id = #{id} and username = #{username}
    </select>
</mapper>

User實體類

public class User {
    private Integer id;
    private String username;
    public User() {
    }
    public User(Integer id, String username) {
        this.id = id;
        this.username = username;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                '}';
    }
}

框架端

創(chuàng)建?個Maven??程并且導(dǎo)?需要?到的依賴坐標

<properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
 <java.version>1.8</java.version>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
 <dependency>
 <groupId>mysql</groupId>
 <artifactId>mysql-connector-java</artifactId>
 <version>5.1.17</version>
 </dependency>
 
 <dependency>
 <groupId>c3p0</groupId>
 <artifactId>c3p0</artifactId>
 <version>0.9.1.2</version>
 </dependency>
 
 <dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>1.2.12</version>
 </dependency>
 
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>4.10</version>
 </dependency>
 
 <dependency>
 <groupId>dom4j</groupId>
 <artifactId>dom4j</artifactId>
 <version>1.6.1</version>
 </dependency>
 
 <dependency>
 <groupId>jaxen</groupId>
 <artifactId>jaxen</artifactId>
 <version>1.1.6</version>
 </dependency>
</dependencies>

Configuration配置類

public class Configuration {
    private DataSource dataSource;
    /**
     * key:statementId value:封裝好的mappedStatement對象
     */
    private Map<String,MappedStatement> mappedStatementMap = new HashMap<>();
    public DataSource getDataSource() {
        return dataSource;
    }
    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }
    public Map<String, MappedStatement> getMappedStatementMap() {
        return mappedStatementMap;
    }
    public void setMappedStatementMap(Map<String, MappedStatement> mappedStatementMap) {
        this.mappedStatementMap = mappedStatementMap;
    }
}

MappedStatement類

public class MappedStatement {
    //sql語句id
    private String id;
    //sql語句
    private String sql;
    //輸入?yún)?shù)類型
    private String parameterType;
    //返回參數(shù)類型
    private String resultType;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getSql() {
        return sql;
    }
    public void setSql(String sql) {
        this.sql = sql;
    }
    public String getParameterType() {
        return parameterType;
    }
    public void setParameterType(String parameterType) {
        this.parameterType = parameterType;
    }
    public String getResultType() {
        return resultType;
    }
    public void setResultType(String resultType) {
        this.resultType = resultType;
    }
}

Resources類

public class Resources {
    //以流的形式讀取配置文件
    public static InputStream getResourceAsStream(String path){
        InputStream resourceAsStream = Resources.class.getClassLoader().getResourceAsStream(path);
        return resourceAsStream;
    }
}

SqlSessionFactoryBuilder類

public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream inputStream) throws PropertyVetoException, DocumentException {
        //使用dom4j解析配置文件,將解析出來的內(nèi)容封裝到Configuration中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        //創(chuàng)建sqlSessionFactory工廠對象:生產(chǎn)sqlSession
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}

XMLConfigBuilder類

public class XMLConfigBuilder {
    private Configuration configuration;

    public XMLConfigBuilder() {
        this.configuration = new Configuration();
    }

    /**
     * 使用dom4j對配置文件進行封裝,封裝Configuration
     */
    public Configuration parseConfig(InputStream inputStream) throws DocumentException, PropertyVetoException {
        Document document = new SAXReader().read(inputStream);
        Element rootElement = document.getRootElement();
        List<Element> list = rootElement.selectNodes("http://property");
        Properties properties = new Properties();
        list.forEach(element -> {
            String name = element.attributeValue("name");
            String value = element.attributeValue("value");
            properties.setProperty(name, value);
        });

        ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
        comboPooledDataSource.setDriverClass(properties.getProperty("driverClass"));
        comboPooledDataSource.setJdbcUrl(properties.getProperty("jdbcUrl"));
        comboPooledDataSource.setUser(properties.getProperty("username"));
        comboPooledDataSource.setPassword(properties.getProperty("password"));

        configuration.setDataSource(comboPooledDataSource);

        //解析<Mapper>標簽
        List<Element> mapperList = rootElement.selectNodes("http://mapper");
        mapperList.stream()
                .map(x -> x.attributeValue("resource"))
                .map(Resources::getResourceAsStream)
                .forEach(resourceAsStream -> {
                    XmlMapperBuilder xmlMapperBuilder = new XmlMapperBuilder(configuration);
                    try {
                        xmlMapperBuilder.parse(resourceAsStream);
                    } catch (DocumentException e) {
                        e.printStackTrace();
                    }
                });
        return configuration;
    }
}

XMLMapperBuilder類

public class XmlMapperBuilder {
    private Configuration configuration;

    public XmlMapperBuilder(Configuration configuration) {
        this.configuration = configuration;
    }

    public void parse(InputStream inputStream) throws DocumentException {
        Document document = new SAXReader().read(inputStream);
        Element rootElement = document.getRootElement();

        String namespace = rootElement.attributeValue("namespace");

        List<Element> list = rootElement.selectNodes("http://select");
        list.forEach(element -> {
            String id = element.attributeValue("id");
            String parameterType = element.attributeValue("parameterType");
            String resultType = element.attributeValue("resultType");
            String sqlText = element.getTextTrim();
            MappedStatement mappedStatement = new MappedStatement();
            mappedStatement.setId(id);
            mappedStatement.setParameterType(parameterType);
            mappedStatement.setResultType(resultType);
            mappedStatement.setSql(sqlText);
            String key = namespace.concat(".").concat(id);
            configuration.getMappedStatementMap().put(key, mappedStatement);
        });
    }
}

SqlSessionFactory接口及DefaultSqlSessionFactory實現(xiàn)類

public interface SqlSessionFactory {

    SqlSession openSession();
}
public class DefaultSqlSessionFactory implements SqlSessionFactory {

    private Configuration configuration;

    public DefaultSqlSessionFactory(Configuration configuration) {
        this.configuration = configuration;
    }
    @Override
    public SqlSession openSession() {
        return new DefaultSqlSession(configuration);
    }
}

SqlSession接口及DefaultSqlSession實現(xiàn)類

public interface SqlSession {
    //查詢所有
    <E> List<E> selectList(String mappedStatementId,Object... params) throws IllegalAccessException, IntrospectionException, InstantiationException, NoSuchFieldException, SQLException, InvocationTargetException, ClassNotFoundException;
    //根據(jù)條件
    <T> T selectOne(String mappedStatementId,Object... params) throws IllegalAccessException, ClassNotFoundException, IntrospectionException, InstantiationException, SQLException, InvocationTargetException, NoSuchFieldException;

    //為Dao接口生成代理實現(xiàn)類
    <T> T getMapper(Class<T> mapperClass);
}
public class DefaultSqlSession implements SqlSession {
    private Configuration configuration;
    public DefaultSqlSession(Configuration configuration) {
        this.configuration = configuration;
    }
    @Override
    public <E> List<E> selectList(String mappedStatementId, Object... params) throws IllegalAccessException, IntrospectionException, InstantiationException, NoSuchFieldException, SQLException, InvocationTargetException, ClassNotFoundException {
        SimpleExecutor simpleExecutor = new SimpleExecutor();
        MappedStatement mappedStatement = configuration.getMappedStatementMap().get(mappedStatementId);
        List<Object> objectList = simpleExecutor.query(configuration, mappedStatement, params);
        return (List<E>) objectList;
    }
    @Override
    public <T> T selectOne(String mappedStatementId, Object... params) throws IllegalAccessException, ClassNotFoundException, IntrospectionException, InstantiationException, SQLException, InvocationTargetException, NoSuchFieldException {
        List<Object> objectList = selectList(mappedStatementId, params);
        if (objectList.size() == 1) {
            return (T) objectList.get(0);
        } else {
            throw new RuntimeException("查詢結(jié)果為空或者返回結(jié)果過多!");
        }
    }
    @Override
    public <T> T getMapper(Class<T> mapperClass) {
        //使用JDK動態(tài)代理來為Dao接口生成代理對象,并返回
        return (T) Proxy.newProxyInstance(DefaultSqlSession.class.getClassLoader(), new Class[]{mapperClass}, ((proxy, method, args) -> {
            String methodName = method.getName();
            String className = method.getDeclaringClass().getName();
            String mappedStatementId = className.concat(".").concat(methodName);
            //獲取被調(diào)用方法的返回值類型
            Type genericReturnType = method.getGenericReturnType();
            //判斷是否進行了泛型類型參數(shù)化
            if (genericReturnType instanceof ParameterizedType){
                List<Object> objectList = selectList(mappedStatementId, args);
                return objectList;
            }
            return selectOne(mappedStatementId,args);
        }));
    }
}

Executor接口及SimpleExecutor實現(xiàn)類

public interface Executor {

    <E>List<E> query(Configuration configuration, MappedStatement mappedStatement,Object... params) throws SQLException, IntrospectionException, InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchFieldException;
}
public class SimpleExecutor implements Executor {
    @Override
    public <E> List<E> query(Configuration configuration, MappedStatement mappedStatement, Object... params) throws SQLException, IntrospectionException, InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchFieldException {
        //注冊驅(qū)動,獲取連接
        Connection connection = configuration.getDataSource().getConnection();

        //獲取sql語句:select * from user where id = #{id} and username = #{username}
        //轉(zhuǎn)換sql語句:select * from user where id = ? and username = ?
        //轉(zhuǎn)換的過程中,還需要對#{}里面的參數(shù)名稱進行解析存儲
        String sql = mappedStatement.getSql();
        BoundSql boundSql = getBoundSql(sql);

        //獲取預(yù)處理對象:preparedStatement
        PreparedStatement preparedStatement = connection.prepareStatement(boundSql.getSqlText());

        //設(shè)置參數(shù)
        //獲取到了參數(shù)的全路徑
        String parameterType = mappedStatement.getParameterType();
        Class<?> parameterTypeClass = getClassType(parameterType);

        List<ParameterMapping> parameterMappingList = boundSql.getParameterMappingList();
        for (int i = 0; i < parameterMappingList.size(); i++) {
            ParameterMapping parameterMapping = parameterMappingList.get(i);
            String content = parameterMapping.getContent();

            //反射
            Field declaredField = parameterTypeClass.getDeclaredField(content);
            //暴力訪問
            declaredField.setAccessible(true);
            Object o = declaredField.get(params[0]);

            preparedStatement.setObject(i + 1, o);
        }

        //執(zhí)行sql
        ResultSet resultSet = preparedStatement.executeQuery();
        String resultType = mappedStatement.getResultType();
        Class<?> resultTypeClass = getClassType(resultType);

        List<Object> objectList = new ArrayList<>();
        //封裝返回結(jié)果集
        while (resultSet.next()) {
            Object o = resultTypeClass.newInstance();
            //元數(shù)據(jù)
            ResultSetMetaData metaData = resultSet.getMetaData();
            for (int i = 1; i <= metaData.getColumnCount(); i++) {

                // 字段名
                String columnName = metaData.getColumnName(i);
                // 字段的值
                Object value = resultSet.getObject(columnName);

                //使用反射或者內(nèi)省,根據(jù)數(shù)據(jù)庫表和實體的對應(yīng)關(guān)系,完成封裝
                PropertyDescriptor propertyDescriptor = new PropertyDescriptor(columnName, resultTypeClass);
                Method writeMethod = propertyDescriptor.getWriteMethod();
                writeMethod.invoke(o, value);
            }
            objectList.add(o);

        }
        return (List<E>) objectList;
    }

    private Class<?> getClassType(String paramterType) throws ClassNotFoundException {
        if (paramterType != null) {
            Class<?> aClass = Class.forName(paramterType);
            return aClass;
        }
        return null;
    }

    /**
     * 完成對#{}的解析工作
     * 1.將#{}使用?進行代替
     * 2.解析出#{}里面的字段名進行存儲
     *
     * @param sql
     * @return
     */
    private BoundSql getBoundSql(String sql) {
        //標記處理類:配置標記解析器來完成對占位符的解析處理工作
        ParameterMappingTokenHandler parameterMappingTokenHandler = new ParameterMappingTokenHandler();
        GenericTokenParser genericTokenParser = new GenericTokenParser("#{", "}", parameterMappingTokenHandler);
        //解析出來的sql
        String parseSql = genericTokenParser.parse(sql);
        //#{}里面解析出來的參數(shù)名稱
        List<ParameterMapping> parameterMappings = parameterMappingTokenHandler.getParameterMappings();

        BoundSql boundSql = new BoundSql(parseSql, parameterMappings);
        return boundSql;
    }
}

BoundSql類

public class BoundSql {
    private String sqlText; //解析過后的sql

    private List<ParameterMapping> parameterMappingList = new ArrayList<>();

    public BoundSql(String sqlText, List<ParameterMapping> parameterMappingList) {
        this.sqlText = sqlText;
        this.parameterMappingList = parameterMappingList;
    }
    public String getSqlText() {
        return sqlText;
    }

    public void setSqlText(String sqlText) {
        this.sqlText = sqlText;
    }

    public List<ParameterMapping> getParameterMappingList() {
        return parameterMappingList;
    }

    public void setParameterMappingList(List<ParameterMapping> parameterMappingList) {
        this.parameterMappingList = parameterMappingList;
    }
}

GenericTokenParser、ParameterMapping、TokenHandler、ParameterMappingTokenHandler工具類

  • GenericTokenParser:解析${}或#{}中的參數(shù)名稱

  • ParameterMapping:存儲${}或#{}中的參數(shù)名稱

  • TokenHandler:替換${}或#{}處理接口

  • ParameterMappingTokenHandler:替換${}或#{}處理接口的實現(xiàn)類

public class GenericTokenParser {
  private final String openToken; //開始標記
  private final String closeToken; //結(jié)束標記
  private final TokenHandler handler; //標記處理器
  public GenericTokenParser(String openToken, String closeToken, TokenHandler handler) {
    this.openToken = openToken;
    this.closeToken = closeToken;
    this.handler = handler;
  }

  /**
   * 解析${}和#{}
   * @param text
   * @return
   * 該方法主要實現(xiàn)了配置文件、腳本等片段中占位符的解析、處理工作,并返回最終需要的數(shù)據(jù)。
   * 其中,解析工作由該方法完成,處理工作是由處理器handler的handleToken()方法來實現(xiàn)
   */
  public String parse(String text) {
    // 驗證參數(shù)問題,如果是null,就返回空字符串。
    if (text == null || text.isEmpty()) {
      return "";
    }

    // 下面繼續(xù)驗證是否包含開始標簽,如果不包含,默認不是占位符,直接原樣返回即可,否則繼續(xù)執(zhí)行。
    int start = text.indexOf(openToken, 0);
    if (start == -1) {
      return text;
    }

   // 把text轉(zhuǎn)成字符數(shù)組src,并且定義默認偏移量offset=0、存儲最終需要返回字符串的變量builder,
    // text變量中占位符對應(yīng)的變量名expression。判斷start是否大于-1(即text中是否存在openToken),如果存在就執(zhí)行下面代碼
    char[] src = text.toCharArray();
    int offset = 0;
    final StringBuilder builder = new StringBuilder();
    StringBuilder expression = null;
    while (start > -1) {
     // 判斷如果開始標記前如果有轉(zhuǎn)義字符,就不作為openToken進行處理,否則繼續(xù)處理
      if (start > 0 && src[start - 1] == '\\') {
        builder.append(src, offset, start - offset - 1).append(openToken);
        offset = start + openToken.length();
      } else {
        //重置expression變量,避免空指針或者老數(shù)據(jù)干擾。
        if (expression == null) {
          expression = new StringBuilder();
        } else {
          expression.setLength(0);
        }
        builder.append(src, offset, start - offset);
        offset = start + openToken.length();
        int end = text.indexOf(closeToken, offset);
        while (end > -1) {////存在結(jié)束標記時
          if (end > offset && src[end - 1] == '\\') {//如果結(jié)束標記前面有轉(zhuǎn)義字符時
            // this close token is escaped. remove the backslash and continue.
            expression.append(src, offset, end - offset - 1).append(closeToken);
            offset = end + closeToken.length();
            end = text.indexOf(closeToken, offset);
          } else {//不存在轉(zhuǎn)義字符,即需要作為參數(shù)進行處理
            expression.append(src, offset, end - offset);
            offset = end + closeToken.length();
            break;
          }
        }
        if (end == -1) {
          // close token was not found.
          builder.append(src, start, src.length - start);
          offset = src.length;
        } else {
          //首先根據(jù)參數(shù)的key(即expression)進行參數(shù)處理,返回?作為占位符
          builder.append(handler.handleToken(expression.toString()));
          offset = end + closeToken.length();
        }
      }
      start = text.indexOf(openToken, offset);
    }
    if (offset < src.length) {
      builder.append(src, offset, src.length - offset);
    }
    return builder.toString();
  }
}
public class ParameterMapping {

    private String content;

    public ParameterMapping(String content) {
        this.content = content;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}
public interface TokenHandler {
  String handleToken(String content);
}
public class ParameterMappingTokenHandler implements TokenHandler {
	private List<ParameterMapping> parameterMappings = new ArrayList<>();

	// context是參數(shù)名稱 #{id} #{username}

	public String handleToken(String content) {
		parameterMappings.add(buildParameterMapping(content));
		return "?";
	}

	private ParameterMapping buildParameterMapping(String content) {
		ParameterMapping parameterMapping = new ParameterMapping(content);
		return parameterMapping;
	}

	public List<ParameterMapping> getParameterMappings() {
		return parameterMappings;
	}

	public void setParameterMappings(List<ParameterMapping> parameterMappings) {
		this.parameterMappings = parameterMappings;
	}
}

到此這篇關(guān)于手撕MyBatis源碼實現(xiàn)自定義持久層框架的文章就介紹到這了,更多相關(guān)MyBatis自定義持久層框架內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 詳解Spring Data JPA系列之投影(Projection)的用法

    詳解Spring Data JPA系列之投影(Projection)的用法

    本篇文章主要介紹了詳解Spring Data JPA系列之投影(Projection)的用法,具有一定的參考價值,有興趣的可以了解一下
    2017-07-07
  • Java使用POI生成Word文檔簡單代碼示例

    Java使用POI生成Word文檔簡單代碼示例

    Java?POI是一個用于操作Microsoft?Office格式文件的Java庫,包括?Word、Excel和PowerPoint等文件,這篇文章主要給大家介紹了關(guān)于Java使用POI生成Word文檔的相關(guān)資料,需要的朋友可以參考下
    2024-08-08
  • 2022年最新java?8?(?jdk1.8u321)安裝圖文教程

    2022年最新java?8?(?jdk1.8u321)安裝圖文教程

    這篇文章主要介紹了2022年最新java?8?(?jdk1.8u321)安裝圖文教程,截止2022年1月,官方出的jdk1.8目前已更新到8u321的版本,本文通過圖文并茂的形式給大家介紹安裝過程,需要的朋友可以參考下
    2022-08-08
  • 詳解Spring Boot Admin監(jiān)控服務(wù)上下線郵件通知

    詳解Spring Boot Admin監(jiān)控服務(wù)上下線郵件通知

    本篇文章主要介紹了詳解Spring Boot Admin監(jiān)控服務(wù)上下線郵件通知,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-12-12
  • 使用Java構(gòu)造和解析Json數(shù)據(jù)的兩種方法(詳解一)

    使用Java構(gòu)造和解析Json數(shù)據(jù)的兩種方法(詳解一)

    JSON(JavaScript Object Notation) 是一種輕量級的數(shù)據(jù)交換格式,采用完全獨立于語言的文本格式,是理想的數(shù)據(jù)交換格式。接下來通過本文給大家介紹使用Java構(gòu)造和解析Json數(shù)據(jù)的兩種方法,需要的朋友參考下吧
    2016-03-03
  • Java中ArrayList與LinkedList的使用及區(qū)別詳解

    Java中ArrayList與LinkedList的使用及區(qū)別詳解

    這篇文章主要給大家介紹了關(guān)于Java中ArrayList與LinkedList的使用及區(qū)別的相關(guān)資料,ArrayList和LinkedList都是實現(xiàn)了List接口的容器類,用于存儲一系列的對象引用,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2024-11-11
  • MyBatis中如何接收String類型的參數(shù)實現(xiàn)

    MyBatis中如何接收String類型的參數(shù)實現(xiàn)

    這篇文章主要介紹了MyBatis中如何接收String類型的參數(shù)實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • 淺談Maven鏡像更換為阿里云中央倉庫(精)

    淺談Maven鏡像更換為阿里云中央倉庫(精)

    本篇文章主要介紹了Maven鏡像更換為阿里云中央倉庫(精),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-12-12
  • 使用Apache?POI和SpringBoot實現(xiàn)Excel文件上傳和解析功能

    使用Apache?POI和SpringBoot實現(xiàn)Excel文件上傳和解析功能

    在現(xiàn)代企業(yè)應(yīng)用開發(fā)中,數(shù)據(jù)的導(dǎo)入和導(dǎo)出是一項常見且重要的功能需求,Excel?作為一種廣泛使用的電子表格工具,常常被用來存儲和展示數(shù)據(jù),下面我們來看看如何使用Apache?POI和SpringBoot實現(xiàn)Excel文件上傳和解析功能吧
    2025-01-01
  • java泛型常用通配符實例解析

    java泛型常用通配符實例解析

    這篇文章主要介紹了java泛型常用通配符實例解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-01-01

最新評論

河西区| 潼关县| 色达县| 砀山县| 望奎县| 昭苏县| 丰顺县| 茂名市| 措勤县| 神农架林区| 沙田区| 社会| 尼勒克县| 阿拉尔市| 商都县| 内黄县| 互助| 密山市| 凤翔县| 鄂托克旗| 大渡口区| 崇文区| 株洲市| 郯城县| 肥城市| 谷城县| 阿拉尔市| 车致| 大田县| 蒲城县| 怀宁县| 巍山| 晋城| 克什克腾旗| 绥棱县| 富顺县| 商城县| 永昌县| 霸州市| 丰都县| 泸西县|