Fork me on GitHub

升级个人网站框架组件IBatisNet+Castle

今天晚上花了两个小时从Castle网站拿到最新的Castle.Facilities.IBatisNetIntegration代码,将IBatisNet版本升级到1.3.0.0,Castle IOC版本升级到1.0.0.2。升级过程中发现几个问题:
1、IBatisNet的配置文件的格式采用了标准的XML的命名空间:
   原来的providers.config 文件
      <?xml version="1.0" encoding="utf-8" ?>
            <providers>
               <clear/>
                 <provider
                     ……
             </providers>
   更改为
   <?xml version="1.0" encoding="utf-8"?>
          <providers xmlns="http://ibatis.apache.org/providers" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <clear/>
             <provider
                     ……
        </providers>
  原来的SqlMap.config文件
 <?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">
……
</sqlMapConfig>
更改为
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
原来的PO.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="Sequence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="SqlMap.xsd">
……
</sqlMap>
更改为
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="Admin" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
……
</sqlMap>

2、IbatisNet 增加了一个Log4Net的组件:IBatisNet.Common.Logging.Log4Net.dll,就是使用Log4Net纪录日志的包装。Log4Net组件版本升级1.2.9.0
他的配置文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <!-- Register a section handler for the log4net section -->
 <configSections>
  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  <sectionGroup name="iBATIS">
   <section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" />
  </sectionGroup> 
 </configSections>
 
 <!-- This section contains the log4net configuration settings -->
 <log4net>
  <!-- Define some output appenders -->
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
   <param name="File" value="log.txt" />
   <param name="AppendToFile" value="true" />
   <param name="MaxSizeRollBackups" value="2" />
   <param name="MaximumFileSize" value="100KB" />
   <param name="RollingStyle" value="Size" />
   <param name="StaticLogFileName" value="true" />
   <layout type="log4net.Layout.PatternLayout">
    <param name="Header" value="[Header]\r\n" />
    <param name="Footer" value="[Footer]\r\n" />
    <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
   </layout>
  </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
   <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n" />
   </layout>
  </appender>
  
  <!-- Set root logger level to ERROR and its appenders -->
  <root>
   <level value="DEBUG" />
   <appender-ref ref="RollingLogFileAppender" />
   <appender-ref ref="ConsoleAppender" />
  </root>
  
  <!-- Print only messages of level DEBUG or above in the packages -->
  <logger name="Castle.Facilities.IBatisNetIntegration.AutomaticSessionInterceptor">
   <level value="DEBUG" />
  </logger>
 </log4net>
 
 <iBATIS>
  <logging>
   <!--<logFactoryAdapter type="IBatisNet.Common.Logging.Impl.ConsoleOutLoggerFA, IBatisNet.Common">
    <arg key="showLogName" value="true" />
    <arg key="showDataTime" value="true" />
    <arg key="level" value="ALL" />
    <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:SSS" />
   </logFactoryAdapter> --> 
   
   <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net">
    <arg key="configType" value="inline" />
   </logFactoryAdapter> 
  </logging>
 </iBATIS>
</configuration>
3、providers.config文件支持的数据库多了db2,Informix,PostgreSql0.7,Firebird1.7,SQLite3.看来Ibatisnet越来越强大了,极力推荐大家采用Ibatisnet.
posted @ 2005-10-17 21:31  张善友  阅读(8206)  评论(18编辑  收藏  举报