Невозможно прочитать значение файла application.properties, используя context: property-placeholder при весенней загрузке - PullRequest
0 голосов
/ 24 октября 2018

Я использую файл application.properties для общих конфигураций, которые я собираюсь сделать профилем на основе позже.Теперь я использую другой конфигурационный файл root-context.xml, где настроен клиентский бин jaxws.я хочу передать адрес конечной точки для этой конфигурации бина из файла application.properties, используя заполнитель свойства контекста, но он выдает мне следующую ошибку:

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

Вот структура проекта

структура проекта

Вот моя конфигурация src / 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>

основной класс

@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);

    }
}

также одна точка, приложение может разрешить файл: $ {config.monitor.dir} / $ {application.messages.file.name} значение, введенное в корневой контекст, но не адрес конечной точки.что мне здесь не хватает?любезно помогите.я использую загрузочную версию 1.5.17

...