<?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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-lazy-init="false"> <!-- 使用手工配置的注解方式来注入bean -->
<!--<context:annotation-config></context:annotation-config>
--> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<context:component-scan base-package="lg.swjtu" />
<!--
<bean id="user" class="lg.swjtu.webfuse.domain.user.User"></bean>
-->
<!-- 定义受环境影响易变的变量 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean> <!-- 配置sessionFactory, 注意这里引入的包的不同 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy"></bean>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">
true
</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.hbm2ddl.atuo">update</prop>
</props>
</property>
<property name="packagesToScan"
value="lg.swjtu.webfuse.domain.*">
</property>
</bean> <!-- <bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean> --> <!-- <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> -->

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <aop:config>
<aop:advisor
pointcut="execution(* lg.swjtu.webfuse.web.*.*(..))"
advice-ref="txAdvice" />
</aop:config>

<tx:annotation-driven transaction-manager="transactionManager"/>

<tx:advice id="txAdvice"  >
<tx:attributes>
<tx:method name="*insert*" />
<tx:method name="*save*" />
<tx:method name="*update*" />
<tx:method name="*delete*" />
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
</beans>

解决方案 »

  1.   

    不错,差不多和我一样配的,我还配了自动扫描action~新建一个classpathscan……~
      

  2.   

    嘿嘿,,有点问题啊,,jpa扫射不了,,不能生产数据库表
      

  3.   

    <property name="packagesToScan"
    value="lg.swjtu.webfuse.domain.*">
    </property>
    上次我也出现了 这个情况 我只是改了下这里 value="lg.swjtu.webfuse.domain">。然后 就ok了 。。
     不知道是不是这个原因? 我自己都很迷糊 。why? 
      

  4.   

    这个配置文件spring文档写的不是很详细吗?
      

  5.   

    <property name="packagesToScan" value="lg.swjtu.webfuse.domain.*"></property> 修改为<property name="packagesToScan" value="lg.swjtu.webfuse.domain"></property>