springboot匯入多個配置檔案
阿新 • • 發佈:2018-11-11
springboot匯入配置檔案的類如下:
package com.upin.config; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource(locations = {"classpath:spring-quartz-task*.xml","classpath:spring-test.xml"}) public class QuartzConfig { }
spring-test.xml配置檔案如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- 測試定時任務 --> <bean id="testQuartz" class="com.upin.service.impl.TestQuartzService"/> </beans>
spring-quartz-task.xml配置檔案如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"/> <!-- 針對自動還款計劃操作 --> <bean id="hkjh" class="com.upin.service.impl.RefundServiceImpl"/> <!-- 定時任務配置 --> <bean id="initQuartzJob" class="com.upin.quartz.InitQuartzJob"/> </beans>