Cannot import properties after integrating spring -batch-admin into existing spring boot

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

I followed the exact rules for how to integrate it: 1. removing all @EnableBatchProcessing 2. adding ServletConfiguration and WebappConfiguration (as well as importing them using

@Import({ ServletConfiguration.class, WebappConfiguration.class })
  1. add details:

    batch-mysql.properties

    MySQL business diagrams

and modified application.properties with:

server.servletPath=/*
spring.freemarker.checkTemplateLocation=false
ENVIRONMENT=mysql

Now here is a side effect. My application uses applicationContext.xml in addition to it java config.

that applicationContext has some placeholders:

  <context:property-placeholder
            location="file:///etc/location/services/myapp.properties"/>


    <bean name="configuration" class="com.mycompany.commons.configuration.factory.BeanAwareConfigurationFactory">

        <property name="serviceId" value="${serviceId}"/>
       ...
    </bean>

As soon as I turned on spring-batch-admin, I got this error:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'serviceId' in string value "${serviceId}"
    at 
...

I tried @PropertySource to import it, but it did not work:

  @PropertySource("file:///etc/location/services/myapp.properties")
    public class Application extends SpringBootServletInitializer {

        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
            System.out.printf("Started processor service app");
        }

spring-batch-admin spring-boot, .

, ?

+4
2

spring-batch-admin. src/main/resources/META-INF/spring/batch/override/manager/ env-context.xml , .

spring batch admin, , - :

<?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>
+3

All Articles