1. 程式人生 > 實用技巧 >mybatis-config.xml配置

mybatis-config.xml配置

`


<properties resource="db.properties"></properties>
<settings>
    <!-- 列印查詢語句 -->
    <setting name="logImpl" value="STDOUT_LOGGING" />
    <!-- 控制全域性快取(二級快取)-->
    <setting name="cacheEnabled" value="true"/>
    <!-- 延遲載入的全域性開關。當開啟時,所有關聯物件都會延遲載入。預設 false  -->
    <setting name="lazyLoadingEnabled" value="true"/>
    <!-- 當開啟時,任何方法的呼叫都會載入該物件的所有屬性。預設 false,可通過select標籤的 fetchType來覆蓋-->
    <setting name="aggressiveLazyLoading" value="false"/>
    <!--  Mybatis 建立具有延遲載入能力的物件所用到的代理工具,預設JAVASSIST -->
    <!--<setting name="proxyFactory" value="CGLIB" />-->
    <!-- STATEMENT級別的快取,使一級快取,只針對當前執行的這一statement有效 -->
    <!--
            <setting name="localCacheScope" value="STATEMENT"/>
    -->
    <setting name="localCacheScope" value="SESSION"/>
</settings>

<typeAliases>
    <typeAlias alias="blog" type="com.wuzz.domain.Blog" />
</typeAliases>

  <!--    <typeHandlers>
    <typeHandler handler="com.wuzz.type.MyTypeHandler"></typeHandler>
</typeHandlers>-->

<!-- 物件工廠 -->
  <!--    <objectFactory type="com.wuzz.objectfactory.GPObjectFactory">
    <property name="wuzz" value="666"/>
</objectFactory>-->

  <!--    <plugins>
    <plugin interceptor="com.wuzz.interceptor.SQLInterceptor">
        <property name="wuzz" value="betterme" />
    </plugin>
    <plugin interceptor="com.wuzz.interceptor.MyPageInterceptor">
    </plugin>
</plugins>-->

<environments default="development">
    <environment id="development">
        <transactionManager type="JDBC"/><!-- 單獨使用時配置成MANAGED沒有事務 -->
        <dataSource type="POOLED">
            <property name="driver" value="${jdbc.driver}"/>
            <property name="url" value="${jdbc.url}"/>
            <property name="username" value="${jdbc.username}"/>
            <property name="password" value="${jdbc.password}"/>
        </dataSource>
    </environment>
</environments>

<mappers>
    <mapper resource="BlogMapper.xml"/>
    <mapper resource="BlogMapperExt.xml"/>
</mappers>

  </configuration>



  `

引用 https://www.cnblogs.com/wuzhenzhao/p/11092526.html