Spring.net 的常用配置格式
web.config
<configuration>
<!--
自定义配置节点声明: 只是声明 具体的内容在随后的节点中出现
知道是配容器和配容器里的对象的 但是不知道怎么理解
另外这个节点要放在第一个 不然会报错的。
-->
<configSections>
<!--sectionGroup 呵呵 为了满足某种结构的定义-->
<!--日志文件自定义配置的生命-->
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
<!--spring的自定义配置-->
<sectionGroup name="spring">
<!--Creates an IApplicationContext instance using context definitions supplied in a custom configuration and configures the ContextRegistry with that instance.-->
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<!--Configuration section handler for the (recommended, Spring.NET standard) parsers config section. -->
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
</sectionGroup>
<!-- 定义 关于数据库的配置 -->
<section name="databaseSettings" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<!-- choices are INLINE, FILE, FILE-WATCH, EXTERNAL-->
<!-- otherwise BasicConfigurer.Configure is used -->
<!-- log4net configuration file is specified with key configFile-->
<arg key="configType" value="FILE-WATCH"/>
<arg key="configFile" value="~/Config/Log4Net.xml"/>
</factoryAdapter>
</logging>
</common>
<spring>
<parsers>
<!--Implementation of the custom configuration parser for database definitions. -->
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
<!--allowing for the configuration of declarative transaction management using either XML or using attributes.
This namespace handler is the central piece of functionality in the Spring transaction management facilities and offers two appraoches to declaratively manage transactions.
One approach uses transaction semantics defined in XML using the -->
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/>
</parsers>
<context>
<resource uri="~/Config/Aspects.xml"/>
<resource uri="assembly://Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao/Dao.xml"/>
<resource uri="assembly://Spring.Northwind.Service/Spring.Northwind.Service/Services.xml"/>
<resource uri="~/Web.xml"/>
</context>
</spring>
<!-- These properties are referenced in Dao.xml -->
<databaseSettings>
<add key="db.datasource" value=".; Integrated Security=true; AttachDbFilename=|DataDirectory|northwnd.mdf; User Instance=true;"/>
<add key="db.user" value="springqa"/>
<add key="db.password" value="springqa"/>
<add key="db.database" value="Northwind"/>
</databaseSettings>
浙公网安备 33010602011771号