Cannot read application.properties file value using context:property-placeholder in spring boot

I am using application.properties file for generic configurations which i intend to do profile based later on. Now i am using another config file root-context.xml where jaxws client bean is configured. i want to pass the endpoint address for that bean configuration from application.properties file using context property placeholder but it is throwing me following error:

Caused by: java.io.IOException: java.net.URISyntaxException: Illegal character in path at index 1: ${sample_endpoint}

Here is the project structure

project structure

Here is my configurationsrc/main/resources/application.properites

config.monitor.dir=C:\/Users/xxx/Documents/resources/artifacts
application.config.file.name=application-config
sample_endpoint=http://xx.x.x/sampleInquiry/01

src/main/resources/root-context.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" xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:cxf="http://cxf.apache.org/core"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
       http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
       http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


    <context:property-placeholder location="classpath:application.properties"/>

    <bean id="messagesSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basenames">
            <list>

                <value>file:${config.monitor.dir}/${application.messages.file.name}
                </value>
            </list>
        </property>
        <property name="cacheSeconds" value="30" />
        <property name="defaultEncoding" value="UTF-8" />
    </bean>

    <bean id="messages"
        class="com.project.microservices.sampleproject.config.Messages"
        scope="application">
        <property name="messagesSource" ref="messagesSource" />
    </bean>


    <jaxws:client id="sampleClient" serviceClass="com.sample.wsdl.sampleInq"
        address="${sample_endpoint}">

        <jaxws:inInterceptors>
            <bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
            <!-- <ref bean="loggingInInterceptor" /> -->
        </jaxws:inInterceptors>
        <jaxws:outInterceptors>
            <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
            <!-- <ref bean="loggingOutInterceptor" /> -->
            <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
                <constructor-arg>
                    <map>
                        <entry key="action" value="UsernameToken" />
                        <entry key="user" value="website" />
                        <entry key="user" value="website" />
                        <entry key="passwordType" value="PasswordText" />
                        <entry key="passwordCallbackRef" value-ref="myPasswordCallback" />
                    </map>
                </constructor-arg>
            </bean>
        </jaxws:outInterceptors>
    </jaxws:client>

main class

@SpringBootApplication
public class SampleApplication extends SpringBootServletInitializer implements WebApplicationInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SampleApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(SampleApplication.class, args);

    }
}

also one point, application is able to resolve file:${config.monitor.dir}/${application.messages.file.name} value mentined in the root-context but not the endpoint address. what i am missing here? kindly help. i am using boot version 1.5.17

0 ответов