zoukankan      html  css  js  c++  java
  • MyBatis XML 配置文件 properties 元素扩展

    在分析 MyBatis XML 配置文件 properties 元素时提到了三种配置方式,其中 property 子元素 和 properties 文件都比较容易理解,但是为什么还要提供一种代码参数传递的方式呢?

    假设一种使用场景,生产环境的数据库联系方式是加密的,故需要 jdbc.properties 文件中以密文的形式保存,而 MyBatis 默认不支持直接解密读取,此时就需要程序进行解密读取。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    String configResource = "mybatis-config.xml";
    InputStream configInputStream = Resources.getResourceAsStream(configResource);

    大专栏  MyBatis XML 配置文件 properties 元素扩展>String propertiesResource = "jdbc.properties";
    InputStream propertiesInputStream = Resources.getResourceAsStream(propertiesResource);
    Properties properties = new Properties();
    properties.load(propertiesInputStream);

    properties.setProperty(decode(properties.getProperty("key")));
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream, properties);

    实现解密方法:

    1
    2
    3
    private String decode(String value) {
    // TODO
    }

    这里只是介绍一种使用思路

  • 相关阅读:
    wim文件位置
    用DISM++来管理wim当中的驱动
    交易所基金代码段
    systemd配置nginx
    MACD公式
    nginx配置
    linux的tmfps
    nohup&
    geth
    RGB
  • 原文地址:https://www.cnblogs.com/lijianming180/p/12037716.html
Copyright © 2011-2022 走看看