You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hotel-management-background.../target/classes/applicationContext.xml

77 lines
3.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!--spring的配置文件 这里主要配置和业务逻辑有关的配置-->
<!--组件扫描 扫描service和mapper pojo实体类-->
<context:component-scan base-package="comxyp">
<!--除了controller的扫描 因为在spring-mvc文件中我们已经扫描 所以这里扫描除这个包之外的前提组件包-->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:exclude-filter>
</context:component-scan>
<!--加载jdbc.properties文件-->
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<!--数据源的配置-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!--配置和mybatis的整合-->
<!--配置sessionFactory 工厂模式-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--数据源-->
<property name="dataSource" ref="dataSource"></property>
<!--加载mybatis核心文件-->
<property name="configLocation" value="classpath:sqlMapConfig.xml"></property>
<!--指定mybatis mapper配置文件的位置-->
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
<!--配置实体类-->
<!--<property name="typeAliases" value="comxyp.pojo"></property>-->
</bean>
<!--扫描mapper所在的包 接口 为mapper创建实现类-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="comxyp.mapper"></property>
</bean>
<!--声明式事务控制-->
<!--平台事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!--控制数据源-->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--开启基于注解的事务 使用xml配置形式的事务主要使用xml配置-->
<!--配置事务增强 事务如何切入-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--所有方法都是事务方法-->
<tx:method name="*" propagation="SUPPORTS"/>
<!--以get开始的所有方法-->
<tx:method name="get*"></tx:method>
</tx:attributes>
</tx:advice>
<!--事务的aop织入-->
<aop:config>
<!--切入点表达式-->
<!--两种方法都可以实现 但是我们一般用下面一种-->
<!--<aop:pointcut id="mypointcut" expression="execution(* comxyp.service..*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="mypointcut"></aop:advisor>-->
<aop:advisor advice-ref="txAdvice" pointcut="execution(* comxyp.service..*.*(..))"></aop:advisor>
</aop:config>
</beans>