您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在spring batch admin中加载外部配置文件

在spring batch admin中加载外部配置文件

Spring Batch管理员在特定路径中搜索配置。此页面说明了它从哪个路径加载资源:

<import resource="classpath*:/Meta-INF/spring/batch/bootstrap/**/*.xml"/>
<import resource="classpath*:/Meta-INF/spring/batch/override/**/*.xml"/>

请注意,在Spring Batch Admin发行版中,“覆盖”位置中没有文件。这是供用户添加自己的内容的占位符。

我们设法加载外部属性文件,并在src/main/resources/Meta-INF/spring/batch/override/manager/env- context.xml其中放置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.xsd">

    <!-- Use this to set additional properties on beans at run time -->
    <bean id="placeholderProperties"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties</value>
                <value>classpath:batch-default.properties</value>
                <value>classpath:batch-${ENVIRONMENT:hsql}.properties</value>
                <value>classpath:batch-${ENVIRONMENT:MysqL}.properties</value>
                <!-- here we load properties from external config folder -->
                <value>file:${spring.file.location}</value>
             </list>
        </property>
        <property name="systemPropertiesModeName" value="SYstem_PROPERTIES_MODE_OVERRIDE" />
        <property name="ignoreResourceNotFound" value="false" />
        <property name="ignoreUnresolvablePlaceholders" value="false" />
        <property name="order" value="1" />
    </bean>
</beans>
Java 2022/1/1 18:36:20 有377人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶