<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
">
<!-- 开启注解扫描 -->
<context:component-scan base-package="cn.dtw"></context:component-scan>
<!-- 读取配置文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 数据源 使用c3p0连接,需要jar包支持 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="${jdbcUrl}"></property>
<property name="driverClass" value="${driverClass}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean>
<!-- 集成Mybatis(sqlSessionFactory )-->
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="typeAliasesPackage" value="cn.dtw"></property>
</bean>
<!-- 映射帮助类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sessionFactory"></property>
<property name="basePackage" value="cn.dtw.dao"></property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 事务注解 -->
<tx:annotation-driven/>
<!-- mvc注解驱动 -->
<mvc:annotation-driven/>
<!-- 处理静态资源 -->
<mvc:default-servlet-handler/>
<!-- 注册异常处理 -->
<bean id="exceptionHandler" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="error"></property>
<property name="exceptionAttribute" value="exp"></property>
<property name="exceptionMappings">
<props>
<prop key="cn.dtw.exception.MyException">myError</prop>
</props>
</property>
</bean>
<!-- 支持上传文件 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 指定默认的编码格式,默认是ISO-8859-1 -->
<property name="defaultEncoding" value="utf-8"></property>
<!-- 上传文件的最大值,单位是字节 -->
<property name="maxUploadSize" value="10000000"></property>
<!-- 上传文件的临时文件夹 -->
<property name="uploadTempDir" value="tempDir"></property>
</bean>
<!-- 视图处理 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 使用动态代理技术 -->
<!--
<bean id="logAspect" class="cn.dtw.aop.LogAspect"></bean>
<aop:config>
切入点
<aop:pointcut expression="execution(public java.lang.Integer addCar(cn.dtw.entity.Car))" id="pointcut"/>
<aop:pointcut expression="execution(* cn.dtw.service.*.*(..))" id="pointcut"/>
切入面
<aop:aspect ref="logAspect">
<aop:before method="before" pointcut-ref="pointcut"/>
</aop:aspect>
</aop:config>
-->
<bean id="logAspect" class="cn.dtw.aop.LogAspect"></bean>
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>
————————————————
版权声明:本文为CSDN博主「Faith_chao」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Faith_chao/article/details/79755399