WinForm下的Nhibernate+Spring.Net的框架配置文件
1.先将配置文件放到如下:<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!--Spring配置声明-->
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<connectionStrings>
<!--批量数据上传-->
<add name="ConnStr" connectionString="server=.;uid=sa;pwd=123;database=spt;"/>
</connectionStrings>
<!--Spring配置声明-->
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data" />
</parsers>
<context>
<!--<resource uri="~/Configs/CommonDao.xml" />-->
<resource uri="file://~/Configs/CommonDao.xml" />
<resource uri="~/Configs/UserDao.xml" />
<resource uri="~/Configs/UserService.xml" />
<resource uri="~/Configs/Form.xml" />
</context>
</spring>
<appSettings>
</appSettings>
</configuration>
对于配置中的外接的xml文件,如上面所示的:<resource uri="file://~/Configs/CommonDao.xml" /> 必须将这个xml文件的属性:输出到输出目录设置为始终复制,因为~代表的是项目生成后exe所在的目录。不如出现错误同http://forum.springframework.net/archive/index.php/t-2929.html
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:tx="http://www.springframework.net/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:db="http://www.springframework.net/database">
<!-- Database and NHibernate Configuration -->
<db:provider id="DbProvider"
provider="SqlServer-2.0"
connectionString="server=.;uid=sa;pwd=123;database=spt;"/>
<object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingAssemblies">
<list>
<value>Hksj.CommonApp.DaoHibernate</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<entry key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<!--<entry key="show_sql" value="true" />-->
</dictionary>
</property>
</object>
<object id="HibernateTransactionManager"
type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
<property name="DbProvider" ref="DbProvider"/>
<property name="SessionFactory" ref="NHibernateSessionFactory"/>
</object>
<object id="HibernateTemplate" type="Spring.Data.NHibernate.HibernateTemplate">
<property name="SessionFactory" ref="NHibernateSessionFactory" />
<property name="TemplateFlushMode" value="Auto" />
<property name="CacheQueries" value="true" />
</object>
</objects>
其中又报错:session不能create
后来发现:<property name="MappingAssemblies">
<list>
<value>Hksj.CommonApp.DaoHibernate< /value>
</list>
</property>配置的加粗部分是类的映射文件所在项目集的名称,在右击项目属性里面拷贝出来,我的有点变化,所有老是报错。
配置好了,错误怎么查看,一定要点开里面innerexception
如下图所示:

3.类映射文件的属性一定设置为嵌入资源
WinForm下的Nhibernate+Spring.Net的框架配置文件的更多相关文章
- Spring.Net+Nhibernate+Asp.Net Mvc 框架
搭建你的Spring.Net+Nhibernate+Asp.Net Mvc 框架 (一)搭建你的环境 使用这套框架不是很长时间.但也基本应用了几个项目中了.在此和大家分享一下我是怎样一步一步搭建此框架 ...
- 在spring+springMvc+mabatis框架下集成swagger
我是在ssm框架下集成swagger的,具体的ssm搭建可以看这篇博文: Intellij Idea下搭建基于Spring+SpringMvc+MyBatis的WebApi接口架构 本项目的GitHu ...
- Eclipse下面的Maven管理的SSH框架整合(Struts,Spring,Hibernate)
搭建的环境:eclispe下面的maven web项目 Struts: 2.5.10 Spring: 4.3.8 Hibernate: 5.1.7 .Final MySQL: 5. ...
- hibernate+spring+mvc+Easyui框架模式下使用grid++report的总结
最近刚开始接触hibernate+spring+mvc+Easyui框架,也是刚开通了博客,希望能记录一下自己实践出来的东西,让其他人少走弯路. 转让正题,以个人浅薄的认识hibernate对于开发人 ...
- spring整合Quartz框架过程,大家可以参考下
这篇文章详细介绍了spring集成quartz框架流程,通过示例代码进行了详细说明,对学习或任务有参考学习价值,并可供需要的朋友参考. 1.quartz框架简介(m.0831jl.com) quart ...
- Winform下CefSharp的引用、配置、实例与报错排除(源码)
Winform下CefSharp的引用.配置.实例与报错排除 本文详细介绍了CefSharp在vs2013..net4.0环境下,创建Winfrom项目.引用CefSharp的方法,演示了winfro ...
- 分享在winform下实现模块化插件编程
其实很早之前我就已经了解了在winform下实现插件编程,原理很简单,主要实现思路就是:先定一个插件接口作为插件样式及功能的约定,然后具体的插件就去实现这个插件接口,最后宿主(应用程序本身)就利用反射 ...
- Spring+SpringMvc+Mybatis框架集成搭建教程二(依赖配置及框架整合)
依赖导入以及框架整合 (1).打开项目的pom.xml文件,声明依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" x ...
- Spring的JDBC框架
转自: http://www.cnblogs.com/windlaughing/p/3287750.html Spring JDBC提供了一套JDBC抽象框架,用于简化JDBC开发. Spring主要 ...
随机推荐
- PAT005 Path in a Heap
题目: Insert a sequence of given numbers into an initially empty min-heap H. Then for any given index ...
- linux驱动开发---导出内核符号
导出内核符号模板代码,验证小实例: /** *Copyright (c) 2013.TianYuan *All rights reserved. * *文件名称: Esdexp.c *文件标识: 导出 ...
- mac os下android 通过battery-historian进行电量分析
简单介绍下如何用battery-historian进行电量分析,因为battery-hostorian是基于go语言的框架,所以需要安装go 1.安装go 2.配置go环境变量到.bash_profi ...
- Aop检查Session,全局过滤器和No全局过滤器
全局过滤器: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...
- spark(1.1) mllib 源码分析(一)-卡方检验
原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/4019131.html 在spark mllib 1.1版本中增加stat包,里面包含了一些统计相关的函数 ...
- 自定义字体TextView
/** * 备注: * 作者:王莹 * 时间:2017/5/4. * ~_~想睡觉了!! * (-o-)~zZ我想睡啦- * π_π?打瞌睡 */ public class FontsTextView ...
- Java知识点梳理——继承
1.定义:继承允许创建分等级层次的类,就是子类继承父类的特征行为,使得子类对象具有父类实例的方法, 使得子类具有父类相同的行为. 2.继承的特性: a.子类拥有父类非priavte的属性.方法: ...
- elasticsearch.net search入门使用指南中文版
原文:http://edu.dmeiyang.com/book/nestusing.html elasticsearch.net为什么会有两个客户端? Elasticsearch.Net是一个非常底层 ...
- PAT Advance 1020
题目: 1020. Tree Traversals (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue S ...
- 学习-go语言坑之for range
引用自 http://studygolang.com/articles/9701 go只提供了一种循环方式,即for循环,在使用时可以像c那样使用,也可以通过for range方式遍历容器类型如数组. ...