Can't Import properties after integrating spring-batch-admin into existed spring boot

后端 未结 2 1915
小鲜肉
小鲜肉 2021-01-13 14:18

I have worked on a project using spring-batch and spring-boot.

I followed the exact rules how to integrate it by: 1. removing all @EnableBatchProcessing 2. adding Se

相关标签:
2条回答
  • 2021-01-13 14:50

    You can override spring-batch-admindefault context loading configuration. In src/main/resources/META-INF/spring/batch/override/manager/ you can place env-context.xml file with configuration of resources which need to be loaded.

    Here is spring batch admin one which can be used as starting point so you can do something like:

    <?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>
                    <!-- this line you can add-->
                    <value>file:///etc/location/services/myapp.properties</value>  
                </list>
            </property>
            <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
            <property name="ignoreResourceNotFound" value="true" />
            <property name="ignoreUnresolvablePlaceholders" value="false" />
            <property name="order" value="1" />
        </bean>
    
    </beans>
    
    0 讨论(0)
  • 2021-01-13 15:03

    I forked the github project and I added the fix to prevent the placeholder error. You can get the new code here: https://github.com/vesperaba/spring-batch-admin-spring-boot.

    The issue was SpringBatch has it's own PropertyPlaceholder and you have to overwrite it but to do that you have to manually import some files in order to avoid the one define it.

    Here you can find the new conf: https://github.com/vesperaba/spring-batch-admin-spring-boot/blob/master/src/main/java/de/codecentric/batch/config/MainV2Configuration.java

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