【发布时间】:2016-03-04 22:17:46
【问题描述】:
Environment:
Spring MVC : 4.1.7.RELEASE
CXF: 3.0.0
java: 1.8
web.xml --- loads appContext.xml (spring cofigs) & cxfContext.xml (configs for cxf)
spring-servlet.xml --- loading the spring mvc configs.
我正在使用下面的方式来加载属性文件。
@Configuration
@PropertySource(value = { "classpath:config.properties" })
public class Configuration {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
属性正在得到解决,除了一种情况外没有任何问题。
我将 CXF 用于 Web 服务,但使用 "${addressVal}" 时地址属性未得到解析。除了 "jaxws:client" 之外,xml 中的所有其他属性都已加载。
<jaxws:client id="port"
serviceClass="com.service.Myclass"
address="${addressVal}" />
问题出在哪里。我做错了什么。
servlet 上下文/应用程序上下文加载问题?
请指教。
【问题讨论】:
-
使用命名空间时,由该命名空间的实现者来正确解析占位符,如果没有实现,它将不起作用。
-
亲爱的 M.Deinum, 感谢您的评论。 “jaxws:client”是 CXF 给出的命名空间。 (cxf.apache.org/jaxwscxf.apache.org/schemas/jaxws.xsd">)。当没有 Spring MVC 时,它更早地工作。但是当我们转移到 Spring MVC 时,它并没有解析属性。
-
如果它工作正常,您更改了配置中的某些内容。我的猜测是您的 cxf 内容加载在未加载/使用
PropertySourcesPlaceholderConfigurer的配置中。 -
我们对整个框架进行了改进,将 Spring MVC 用于 REST 控制器。我正在将 cxf 的东西加载到 xml 中(cxf 内部仅使用 spring)并且 xml 直接加载到 web.xml 中尝试了我能想到但无法缩小范围的所有可能性。
-
如果你有一个
ContextLoaderListener和一个DispatcherServlet没关系,你有2个上下文,如果属性被加载到1并且其他你的属性中的cxc东西不可用.
标签: spring spring-mvc cxf jax-ws spring-cxf