导入所需要的jar包: xwork-core-2.2.1.jarxwork-core-2.2.1.jar struts2-spring-plugin-2.2.1.jarstruts2-spring-plugin-2.2.1.jar struts2-cor
来源:互联网 发布:淘宝卖图书 编辑:程序博客网 时间:2024/05/17 07:04
- <?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:
- http:
- http:
- http:
- http:
- http:
- http:
- http:
- <!-- 用注解方式注入bean,启动服务器时,spring会到com.yj查找所有带spring的注解(如:@Component),把他们注入到spring中 -->
- <context:annotation-config/>
- <context:component-scan base-package="com.yj"/>
- <!-- hibernate sessionFactory 创建 -->
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- <property name="packagesToScan">
- <list>
- <value>com.yj.model</value>
- </list>
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.format_sql">true</prop>
- <prop key="hibernate.hbm2ddl.auto">auto</prop>
- <prop key="hibernate.show_sql">true</prop>
- <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
- <!--指定Proxool的alias,必须与Proxool的配置文件中的alias一致-->
- <prop key="hibernate.proxool.pool_alias">datasource</prop>
- <!--指定Proxool配置文件-->
- <prop key="hibernate.proxool.xml">proxool.xml</prop>
- <prop key="hibernate.connection.provider_class">
- org.hibernate.connection.ProxoolConnectionProvider
- </prop>
- </props>
- </property>
- </bean>
- <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean>
- <!-- 事物配置 -->
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory"></property>
- </bean>
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="find*" read-only="true"/>
- <tx:method name="add*" propagation="REQUIRED"/>
- <tx:method name="save*" propagation="REQUIRED"/>
- </tx:attributes>
- </tx:advice>
- <aop:config>
- <aop:pointcut expression="execution(public * com.yj.service..*.*(..))" id="myPointcut"/>
- <aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut"/>
- </aop:config>
-
- </beans>