非常全的SSM框架配置文件(applicationContext.xml)

转载时请注明出处和链接地址(URL)

本人是新手,总结了一些SSM框架经常用到的配置,大家如果有好的建议欢迎评论哦,需要下载jar包的同学:https://download.csdn.net/download/faith_chao/10317606


<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"/>
    
    <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>

    
    <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: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">myErrorprop>
            props>
        property>
    bean>

    
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        
        <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:aspectj-autoproxy>aop:aspectj-autoproxy>

beans>

你可能感兴趣的:(框架)