求高手,spring3.2+hibernate4.1整合后数据源问题
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 配置事务传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- aop对哪些类的哪些方法实行事务管理 -->
<aop:config>
<aop:pointcut id="allManager" expression="execution(* com.spg.manager.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManager"/>
</aop:config>
</beans>
hibernate配置
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost/SSH?characterEncoding=UTF-8
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="com/spg/bean/User.hbm.xml" />
<mapping resource="com/spg/bean/Log.hbm.xml" />
</session-factory>
</hibernate-configuration>字数超出限制,错误堆栈信息:见一楼
相关推荐
Spring4+SpringMVC4+Hibernate4整合源码
本资源为Spring4+SpringMVC4+Hibernate4整合源码,里面内置了一套对Hibernate底层Dao的封装,分页的封装,由于最近比较忙暂时没时间集成Spring Security。权限部分也还没来的及实现,本套框架的前端打算用bootstrap,后续会逐步更新本套框架,对于里面的架构存在缺陷的也欢迎各位提意见。
SpringMVC+hibernate4.3+Spring4.1整合demo
一个目前最新版的SSH框架,都是昨天才去官网下载的新包。做了一个简单的登陆功能;
Struts2+Spring3+Hibernate4整合的jar包
给大家一个SSH整合之后的jar包,虽然有几个jar包是多余的,但是我可以保证绝对没有冲突,而且绝对的可以使SSH项目很好的跑起来。
Spring4.0+Hibernate4.0+Struts2.3整合案例
Spring4.0+Hibernate4.0+Struts2.3整合案例:实现增删改查。 ===================== application.xml: ============================================= 解决整合问题: 1、Spring 3.x 对 Hibernate 4.x 不提供 HibernateDaoSupport,所以在dao的实现层注入SessionFactory 2、报错:org.hibernate.HibernateException: No Session found for current thread 意思是必须在transcation.isActive()条件下才能执行, 可以解决办法是:当方法不需要事务支持的时候,使用 Session session = sessionFactory.openSession()来获得Session对象,问题解决!
spring4.1.6+hibernate4.3.9+struts2.3.20整合
一、 项目名称:ssh 项目原型:Struts2.3.20 + Spring4.1.6 + Hibernate4.3.9 二、 项目目的: 整合使用最新版本的三大框架(即Struts2、Spring4和Hibernate4),搭建项目架构原型。 项目架构原型:Struts2.3.20 + Spring4.1.6 + Hibernate4.3.9。 此外,还有:log4j、slf4j、junit4、ehcache等知识点。 项目特色: 同时使用了Struts2、Spring4、Hibernate4、log4j、slf4j、junit4、ehcache等库或框架,搭建一个最基本的项目原型。


Web 开发
