Spring的多模块配置
来源:互联网 发布:兄弟打印机扫描软件 编辑:程序博客网 时间:2024/05/17 00:57
在web.xml文件中:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml,/WEB-INF/classes/applicationContext-*.xml</param-value>
</context-param>
同样还有别的方式配置
比如在struts文件中配置:
比如在主配置文件中通过import子文件来配置:
<import resource="applicationContext-dao.xml"/>
<import resource="applicationContext-service.xml"/>
<import resource="applicationContext-action.xml"/>
在主配置文件中配置共同的东西,applicationContext.xml
<beans ...... >
<context:annotation-config />
<aop:aspectj-autoproxy />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<bean id="txBase" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true" abstract="true">
<!-- 为事务模板注入事务管理器-->
<property name="transactionManager"><ref bean="transactionManager"/></property>
<!-- 设置事务属性-->
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="new*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="mod*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="sAspect" class="com.william61.littleStore.base.SystemAspect" />
<aop:config>
<aop:pointcut id="dataAccessOperation" expression="execution(* com.william61.littleStore.dao.*.*(..))" />
<aop:aspect id="afterThrowingExample" ref="sAspect">
<aop:after-throwing pointcut-ref="dataAccessOperation" throwing="ex" method="dataAccessException" />
</aop:aspect>
</aop:config>
</beans>
在子配置文件中
<bean id="UserDAO" parent="txBase" >
<property name="target">
<bean class="com.william61.littleStore.dao.impl.hbt.authority.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
<!-- <property name="sessionFactory"><ref local="sessionFactory"/></property> 如果是这样会出错的 -->
</bean>
</property>
</bean>
- Spring的多模块配置
- maven多模块下的spring配置
- spring的AOP模块配置示例
- 如何使用多个Spring的xml配置文件(多模块配置)
- 如何使用多个Spring的xml配置文件(多模块配置)
- webx中保留原spring servlet模块的配置
- 如何 在Spring MVC中 使用多个Spring和MyBatis的xml配置文件(多模块配置)
- Spring配置之DAO模块配置示例
- spring-boot 多模块的搭建
- Spring的七大模块
- Spring的七大模块
- Spring的AOP模块
- Spring的七大模块
- Spring的七大模块
- spring 的七大模块
- Spring的七大模块
- Spring 的七大模块
- Spring的模块
- 从EVC4.0迁移到VS2005
- Linux驱动学习记录 devfs_mk_cdev
- C#中的注释
- 使用mysql可视化工具mysql-front的时候遇到软件过期问题
- Object Null 设计模式
- Spring的多模块配置
- 【ASP.NET Chart】MSChart图片保存到硬盘
- POJ 3264 Balanced Lineup(RMQ)
- STL空间构造器
- 来到csdn的第一天
- 别被直觉所蒙蔽(1):有些事并不总是发生
- PC常见问题记录
- JS学习笔记二
- 呵呵