spring 的配置文件 是上个web.xml 加载spring容器中的/WEB-INF/application.xml 文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring 的配置文件 是上个web.xml 加载spring容器中的/WEB-INF/application.xml 文件相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
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/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <!--开启自动扫描Bean  -->
    <context:component-scan base-package="com.lovo" />
    
    <!--开启AOP注解支持  -->
    <aop:aspectj-autoproxy />
    
    <!--配置数据源(c3p0)  -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <!--指定数据库驱动  -->
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
        <!--指定数据库URL  -->
        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/cbd_db"/>
        <!--指定数据库用户名  -->
        <property name="user" value="root"/>
        <!--指定数据库密码  -->
        <property name="password" value="root"/>
        
        <!--指定连接池最大连接数  -->
        <property name="maxPoolSize" value="20" />
        <!--指定连接池最小连接数  -->
        <property name="minPoolSize" value="1" />
        <!--指定初始化连接池连接数(默认3个)  -->
        <property name="initialPoolSize" value="2" />
        <!--指定连接池连接超时时长  -->
        <property name="maxIdleTime" value="5000" />
        <!--指定连接池耗尽时创建连接数  -->
        <property name="acquireIncrement" value="2" />
        <!--指定连接池检测线程间隔时长  -->
        <property name="idleConnectionTestPeriod" value="3000" />
    </bean>
    
    <!--配置jdbc事务管理  -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    
    <!--配置SqlSessionFactory  -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="typeAliasesPackage" value="com.lovo.entity" />
    </bean>
    
    <!--配置Mapper扫描模式,所有Mapper都继承SqlMapper接口  -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.lovo.mapper" />
        <property name="markerInterface" value="com.lovo.mapper.SqlMapper" />
    </bean>
    
</beans>

以上是关于spring 的配置文件 是上个web.xml 加载spring容器中的/WEB-INF/application.xml 文件的主要内容,如果未能解决你的问题,请参考以下文章

web.xml中定义的Spring的XML配置文件启动顺序

spring的配置文件在web.xml中加载的方式

在web.xml正确加载spring配置文件的方式

spring boot框架的web.xml文件怎么配置

Web.xml配置

spring boot框架的web.xml文件怎么配置