Spring的配置文件 (SSM maven项目)

2020-12-13 05:32

阅读:482

标签:指定   use   config   hang   项目   base   核心   word   beans   

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://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/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">

    


    context:component-scan base-package="xyz.sun">
        context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller">context:exclude-filter>
    context:component-scan>

    
    context:property-placeholder location="classpath:dbconfig.properties" />


    bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        property name="jdbcUrl" value="${jdbc.jdbcUrl}">property>
        property name="driverClass" value="${jdbc.driverClass}">property>
        property name="user" value="${jdbc.user}">property>
        property name="password" value="${jdbc.password}">property>

    bean>


    
    bean id="SqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
        
        property name="configLocation" value="classpath:mybatis-config.xml">property>
        property name="dataSource" ref="pooledDataSource">property>
        
        property name="mapperLocations" value="classpath:mapper/*.xml">property>
    bean>

    
    bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        
        property name="basePackage" value="xyz.sun.crud.dao">property>
    bean>




    
    bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        
        property name="dataSource" ref="pooledDataSource">property>
    bean>

    
    aop:config>
        
        aop:pointcut  expression="execution(* xyz.sun.crud.service..*(..))" id="txPoint" />
        
        aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint" />
    aop:config>
    
     
    tx:advice id="txAdvice" transaction-manager="transactionManager">
        tx:attributes>
            
            tx:method name="*" />
            
            tx:method name="get*" read-only="true" />
        tx:attributes>
    tx:advice>

    
beans>
jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_crud?useUnicode=true&characterEncoding=utf8&useSSL=true
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.user=root
jdbc.password=123456

截图:

技术图片

 

Spring的配置文件 (SSM maven项目)

标签:指定   use   config   hang   项目   base   核心   word   beans   

原文地址:https://www.cnblogs.com/mzdljgz/p/11143297.html


评论


亲,登录后才可以留言!