以前都在使用NHibernate,今天终于把SpringNet也加进来了,因为最初是在java中接触的hibernate和spring,而在.net中这两者非常相似,所以我的配置有点模仿java了,看一下使用的版本吧:NHibernate1.2,Springnet1.1,netframework2.0,如今的配置可能有点落伍了,不过先一步一步来,以后还会升级的,看代码: web.config<?xml version="1.0"?><configuration> <configSections> <sectionGroup name="spring"> <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/> <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/> </sectionGroup> <section name="SpringOverrideProperty" type="System.Configuration.NameValueSectionHandler"/> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <spring> <context> <resource uri="config://spring/objects"/> <resource uri="assembly://SpringResource.App/SpringResource/spring_bean_dao.xml"/> </context> <objects xmlns="http://www.springframework.net%22/> </spring> <appSettings /> <system.web> <sessionState timeout="30" mode="StateServer" /> <pages validateRequest="false" /> <globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" uiCulture="zh-CHS"/> <compilation debug="true"> <assemblies /> </compilation> <authentication mode="Windows"/> <httpModules> <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/> </httpModules> <httpHandlers> <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/> </httpHandlers> </system.web></configuration>v 这里面已经使用了springnet的web框架,这样就可以对aspx页面进行依赖注入了............. spring_bean_dao.xml<?xml version="1.0" encoding="utf-8" ?><objects xmlns="http://www.springframework.net/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.net/ http://www.springframework.net/xsd/spring-objects.xsd"> <!--Nhibernate的SessionFactory的封装的对像的定义--> <object /> </dictionary> </property> </object> <!--配置驱动,这里类似java中的驱动包--> <object /> </property> </object> <!-- DAO--> <object /> </object> <!-- BIZ --> <object /> </object> <!-- Aspx --> <object type="~/Default.aspx"> <property name="UserBiz" ref="UserBizImpl" /> </object></objects><?xml version="1.0" encoding="utf-8" ?><objects xmlns="http://www.springframework.net/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.net/ http://www.springframework.net/xsd/spring-objects.xsd"> <!--Nhibernate的SessionFactory的封装的对像的定义--> <object /> </dictionary> </property> </object> <!--配置驱动,这里类似java中的驱动包--> <object /> </property> </object> <!-- DAO--> <object /> </object> <!-- BIZ --> <object /> </object> <!-- Aspx --> <object type="~/Default.aspx"> <property name="UserBiz" ref="UserBizImpl" /> </object></objects> 相关文章: 2021-09-26 2022-12-23 2022-01-24 2021-07-25 2018-07-19 2021-11-07 2021-11-27 2022-12-23