load external config file in spring batch admin

前端 未结 3 995
暗喜
暗喜 2021-01-07 10:20

I downloaded the spring batch admin application in the github repo and I imported it in eclipse. it works perfectly.

Then, I asked myself how to import an external c

相关标签:
3条回答
  • 2021-01-07 10:30

    Spring batch admin searches configurations in specific paths.This page explains from which paths it loads resources:

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

    Note that the "override" location has no files in it in Spring Batch Admin distribution. This is a placeholder for users to add their own content.

    We managed to load external properties files placing xml configuration file under src/main/resources/META-INF/spring/batch/override/manager/env-context.xml which looks like this:

    <?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>
    
    0 讨论(0)
  • 2021-01-07 10:33

    You can put your env-context.xml file on spring/batch/servlet/override/env-context.xml folder.

    0 讨论(0)
  • 2021-01-07 10:52

    Under main folder of spring-batch-admin template, there are three folders - java, resources and webapp. Under resources there are some property files and META-INF folder. within META-INF there are two folders - batch and servlet.

    Here If I want to add new property file "batch.properties" under resources and want to refer the property values from configuration (xml) files from "META-INF/batch/*.xml" in addition to the properties from spring-batch-admin-manager-1.0.0.M1.jar, 1. where to add below entries

    1. Where to keep "env-context.xml". Under which folders, coz in "src/main/resources/META-INF" i can see only one folder batch.

    2. I tried to create "spring/batch/override/manager/env-context.xml" under "src/main/resources/META-INF" but not able to read the property file entries.

    If you provide your working application folder structure will help me a lot.

    0 讨论(0)
提交回复
热议问题