Spring自定义单测加载配置文件

162 阅读1分钟

Spring自定义单测加载配置文件

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

    <!--导入类配置文件-->
    <import resource="path/applicationContext-*-datasource.xml" />
    
    <!--指定包路径扫描指定的类-->
    <context:annotation-config/>
    <context:component-scan base-package="包路径用点分割" use-default-filters="false">
        <context:include-filter type="assignable" expression="类路径.impl.类名"/>
        <context:include-filter type="assignable" expression="类路径.impl.类名"/>
        <context:include-filter type="assignable" expression="类路径.impl.类名"/>
    </context:component-scan>

    <!-- 自定义bean加载-->
    <bean id="***" class="***" init-method="init">
        <property name="threadPoolName" value="***ThreadPool"/>
        <property name="corePoolSize" value="10"/>
        <property name="maximumPoolSize" value="30"/>
        <property name="keepAliveTime" value="60"/>
        <property name="queueCapacity" value="100"/>
        <property name="****">
            <bean class="***"/>
        </property>
    </bean>

</beans>