运行test时无法在applicationcontext-ws.xml中解析$ {url}

问题描述 投票:0回答:1

urlhttp:xxx.com..test/java/resources/application-local.properties中的..main/java/resources/application-local.properties相似

一个名为applicationcontext-ws.xml的文件使用了${url}

<jaxws:client id="xxx"
              serviceClass="RemoteService"
              address="${url}">
    <jaxws:outInterceptors>
        <ref bean="headerInterceptor"/>
    </jaxws:outInterceptors>
</jaxws:client>

运行测试时,我得到一个例外:

引起:java.net.URISyntaxException:索引1处的路径中的非法字符:java.net.URI $ Parser.fail(URI.java:2848)java.net.URI $ Parser.checkChars(URI)中的$ {url} .java:3021)at java.net.URI $ Parser.parseHierarchical(URI.java:3105)at java.net.URI $ Parser.parse(URI.java:3063)at java.net.URI。(URI.java :588)org.apache.cxf.transport.http.HTTPConduit.setupURI(HTTPConduit.java:664)at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:458)

但是,当正常运行它,即没有运行测试时,这个问题永远不会发生。

起初我怀疑是因为..test/resources/application-local.properties没有加载。我在我的测试类中用url注释了一个字段@Value(${url}),在调试模式中,我可以看到字段的值正好是..test/resources/application-local.properties中url的内容,所以这不是原因。

您能否提供一些建议,帮助我找出原因是什么以及如何在运行测试时重新启动url?谢谢。

java spring spring-boot
1个回答
0
投票

我相信'$ {url}'本身就像网址一样,'{'被视为非法角色。请调试并检查在运行时传递/创建的URL是什么。我相信$ {url}在运行时没有被正确替换。

© www.soinside.com 2019 - 2024. All rights reserved.