sessionFactory异常 sessionFactory 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 applicationContext.xml配置文件里面是不是配错了 <?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:context="http://www.springframework.org/schema/context" 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.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <!--配置文件导入 --> <import resource="classpath:applicationContext-ehcache.xml"/> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>classpath:dataSource.properties</value> </property> </bean> <!--数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${mssql.database.driver}"></property> <property name="url" value="${mssql.database.url}"></property> <property name="username" value="${mssql.database.user}"></property> <property name="password" value="${mssql.database.password}"></property> <property name="maxActive" value="${mssql.database.maxActive}"></property> <property name="maxIdle" value="${mssql.database.maxIdle}"></property> <property name="maxWait" value="${mssql.database.maxWait}"></property> </bean> <!--session工厂,里面可以配置Hibernate的映射文件,使用annotatedClasses--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" > <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <value> hibernate.dialect=${hibernate.dialect} hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto} hibernate.show_sql=${hibernate.show_sql} hibernate.format_sql=${hibernate.format_sql} hibernate.cache.use_second_level_cache=${hibernate.cache.use_second_level_cache} hibernate.cache.provider_class=${hibernate.cache.provider_class} hibernate.cache.use_query_cache=${hibernate.cache.use_query_cache} hibernate.jdbc.fetch_size=${hibernate.jdbc.fetch_size} hibernate.jdbc.batch_size=${hibernate.jdbc.batch_size} hibernate.cache.provider_configuration_file_resource_path=${hibernate.cache.provider_configuration_file_resource_path} </value> <!-- <props> hibernate的方言,建议改成MySQL5Dialect <prop key="hibernate.dialect"> org.hibernate.dialect.MySQL5Dialect </prop> 开发的时候尽量打开true <prop key="hibernate.show_sql">false</prop> </props> --> </property> <!-- <property name="hibernate.cache.provider_class"> net.sf.ehcache.hibernate.EhCacheProvider</property> 指定cache实现类 <property name="cache.use_second_level_cache">true</property> 启用二级缓存 <property name="hibernate.cache.use_query_cache">true</property> 启用查询缓存 <property name="hibernate.cache.provider_configuration_file_resource_path">ehcache2.xml</property>//指定ehcache配置文件 --> <!--主键Bean类--> <property name="annotatedClasses"> <list> <value>com.org.entity.WsUsers</value> <value>com.org.entity.SysUsers</value> <value>com.org.entity.ShopApp</value> <value>com.org.entity.Category</value> <value>com.org.entity.Role</value> <value>com.org.entity.Class</value> <value>com.org.entity.WeixXinKeyword</value> <value>com.org.entity.Goods</value> <value>com.org.entity.Goods_brand</value> <value>com.org.entity.Goods_cate</value> <value>com.org.entity.Goods_Order</value> <value>com.org.entity.Goods_Order_Detail</value> <value>com.org.entity.Goods_Img</value> <value>com.org.entity.Ads</value> <value>com.org.entity.Delivery</value> <value>com.org.entity.Alipay</value> <value>com.org.entity.User_Address</value> <value>com.org.entity.Shop_Address</value> <value>com.org.entity.Setting</value> <value>com.org.entity.Alipay</value> <value>com.org.entity.SysConfig</value> <value>com.org.entity.App_subassembly</value> <value>com.org.entity.App_skin</value> <value>com.org.entity.App_Dev_Plan</value> <value>com.org.entity.App_Dev_Menu</value> <value>com.org.entity.App_Dev_Demand</value> <value>com.org.entity.App_Dev_CheckAccept</value> <value>com.org.entity.App_Dev_Assess</value> </list> </property> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!-- 配置事务的传播特性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <!-- 那些类的哪些方法参与事务 --> <aop:config> <!--<aop:pointcut id="allServiceMethod" expression="execution(* com.org.core.dao.*.*.*(..))" /> --> <aop:pointcut id="allServiceMethod" expression="execution(* *.service.*(..))" /> <aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" /> </aop:config> <!-- 使Spring关注Annotation --> <context:annotation-config /> <!-- 让Spring通过自动扫描来查询和管理Bean --> <context:component-scan base-package="com.org" /> <bean id="springUtil" class="com.org.core.utils.SpringUtil" lazy-init="false" /> <bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper" lazy-init="false" /></beans> Dao的实现类里的sessionFactory是不是没有注进去阿? 简单的多线程问题,synchronized的原理 求PD生成hibernate的模版配置文件 tomcat如何实现重新加载class SSH中无法使用update更新字段! 请教 ejb 3.0 remove 的问题 hibernate存取字符串的问题 有关hibernate的问题 数据从JSP页面到数据库再到JSP页面为什么排版格式没了,问题如何解决??谢谢各位,给分100!!! 在jbuiler6中为什么没有javax.sql.DataSource类,怎样解决? 如何编译测试ejb的客户端程序 struts2 下载出错 大哥们给解决一下把 jquery中联动问题!!! 实在是没多少分了
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
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.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!--配置文件导入 -->
<import resource="classpath:applicationContext-ehcache.xml"/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:dataSource.properties</value>
</property>
</bean>
<!--数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${mssql.database.driver}"></property>
<property name="url" value="${mssql.database.url}"></property>
<property name="username" value="${mssql.database.user}"></property>
<property name="password" value="${mssql.database.password}"></property>
<property name="maxActive" value="${mssql.database.maxActive}"></property>
<property name="maxIdle" value="${mssql.database.maxIdle}"></property>
<property name="maxWait" value="${mssql.database.maxWait}"></property>
</bean>
<!--session工厂,里面可以配置Hibernate的映射文件,使用annotatedClasses-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
hibernate.show_sql=${hibernate.show_sql}
hibernate.format_sql=${hibernate.format_sql}
hibernate.cache.use_second_level_cache=${hibernate.cache.use_second_level_cache}
hibernate.cache.provider_class=${hibernate.cache.provider_class}
hibernate.cache.use_query_cache=${hibernate.cache.use_query_cache}
hibernate.jdbc.fetch_size=${hibernate.jdbc.fetch_size}
hibernate.jdbc.batch_size=${hibernate.jdbc.batch_size}
hibernate.cache.provider_configuration_file_resource_path=${hibernate.cache.provider_configuration_file_resource_path}
</value>
<!-- <props>
hibernate的方言,建议改成MySQL5Dialect
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQL5Dialect
</prop>
开发的时候尽量打开true
<prop key="hibernate.show_sql">false</prop>
</props>
-->
</property>
<!--
<property name="hibernate.cache.provider_class"> net.sf.ehcache.hibernate.EhCacheProvider</property> 指定cache实现类
<property name="cache.use_second_level_cache">true</property> 启用二级缓存
<property name="hibernate.cache.use_query_cache">true</property> 启用查询缓存
<property name="hibernate.cache.provider_configuration_file_resource_path">ehcache2.xml</property>//指定ehcache配置文件
-->
<!--主键Bean类-->
<property name="annotatedClasses">
<list>
<value>com.org.entity.WsUsers</value>
<value>com.org.entity.SysUsers</value>
<value>com.org.entity.ShopApp</value>
<value>com.org.entity.Category</value>
<value>com.org.entity.Role</value>
<value>com.org.entity.Class</value>
<value>com.org.entity.WeixXinKeyword</value>
<value>com.org.entity.Goods</value>
<value>com.org.entity.Goods_brand</value>
<value>com.org.entity.Goods_cate</value>
<value>com.org.entity.Goods_Order</value>
<value>com.org.entity.Goods_Order_Detail</value>
<value>com.org.entity.Goods_Img</value>
<value>com.org.entity.Ads</value>
<value>com.org.entity.Delivery</value>
<value>com.org.entity.Alipay</value>
<value>com.org.entity.User_Address</value>
<value>com.org.entity.Shop_Address</value>
<value>com.org.entity.Setting</value>
<value>com.org.entity.Alipay</value>
<value>com.org.entity.SysConfig</value>
<value>com.org.entity.App_subassembly</value>
<value>com.org.entity.App_skin</value>
<value>com.org.entity.App_Dev_Plan</value>
<value>com.org.entity.App_Dev_Menu</value>
<value>com.org.entity.App_Dev_Demand</value>
<value>com.org.entity.App_Dev_CheckAccept</value>
<value>com.org.entity.App_Dev_Assess</value>
</list>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<aop:config>
<!--<aop:pointcut id="allServiceMethod" expression="execution(* com.org.core.dao.*.*.*(..))" /> -->
<aop:pointcut id="allServiceMethod" expression="execution(* *.service.*(..))" />
<aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" />
</aop:config>
<!-- 使Spring关注Annotation -->
<context:annotation-config />
<!-- 让Spring通过自动扫描来查询和管理Bean -->
<context:component-scan base-package="com.org" />
<bean id="springUtil" class="com.org.core.utils.SpringUtil" lazy-init="false" />
<bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper" lazy-init="false" />
</beans>