子类继承父类的配置

修改前:
<?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"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:task="http://www.springframework.org/schema/task"

    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/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd 
        http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task.xsd"
    default-lazy-init="true">
    <!-- 任务定时器 -->
    <task:scheduler id="threadPoolTaskScheduler" pool-size="10" />
    <!--queue-capacity:队列容量;rejection-policy指定执行器队列满时的执行策略 1)ABORT(默认):直接抛出; 
        2)CALLER_RUNS:不会将任务交给执行器线程,而是让调用者线程来执行该任务; 3)DISCARD_OLDEST:丢弃老的政策; 4)DISCARD:丢弃政策 -->
    <task:executor id="threadPoolTaskExecutor" pool-size="10"
        queue-capacity="10" />

    <task:scheduled-tasks scheduler="threadPoolTaskScheduler">
        <task:scheduled ref="autoRemarkDomainOrgDutyPhoneService"
            method="run" cron="0/1 * * * * ?" />
    </task:scheduled-tasks>

    <!-- 父类 -->
    <bean id="autoCoreService" class="com.dscomm.remark.core.task.AbstractxxxService">
        <property name="xxxOperateService" ref="xxxOperateService" />
        <property name="singleObjectOperateFacade" ref="singleObjectOperateFacade" />
    </bean>
    
    <!-- 子类 -->
      <bean id="aaaService"
        class="com.dscomm.remark.regular.coc.execute.AaaServiceImpl">
        <property name="singleObjectOperateFacade" ref="singleObjectOperateFacade" />
      </bean>
</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"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:task="http://www.springframework.org/schema/task"

    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/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd 
        http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task.xsd"
    default-lazy-init="true">
    <!-- 任务定时器 -->
    <task:scheduler id="threadPoolTaskScheduler" pool-size="10" />
    <!--queue-capacity:队列容量;rejection-policy指定执行器队列满时的执行策略 1)ABORT(默认):直接抛出; 
        2)CALLER_RUNS:不会将任务交给执行器线程,而是让调用者线程来执行该任务; 3)DISCARD_OLDEST:丢弃老的政策; 4)DISCARD:丢弃政策 -->
    <task:executor id="threadPoolTaskExecutor" pool-size="10"
        queue-capacity="10" />

    <task:scheduled-tasks scheduler="threadPoolTaskScheduler">
        <task:scheduled ref="autoRemarkDomainOrgDutyPhoneService"
            method="run" cron="0/1 * * * * ?" />
    </task:scheduled-tasks>

    <!-- 父类 -->
    <bean id="autoCoreService" class="com.dscomm.remark.core.task.AbstractxxxService" abstract="true">
        <property name="xxxOperateService" ref="xxxOperateService" />
        <property name="singleObjectOperateFacade" ref="singleObjectOperateFacade" />
    </bean>

    <!-- 子类 -->
      <bean id="aaaService"
        class="com.dscomm.remark.regular.coc.execute.AaaServiceImpl"  parent="autoCoreService">
      </bean>
</beans>

子类配置 parent="父类的ID"  这样,父类注入的属性,子类就不用再注入了,就可以直接父类的属性了。

猜你喜欢

转载自www.cnblogs.com/Alwaysbecoding/p/12342532.html