[英]Spring property place holder is not resolving in jaxws:client (cxf) address property
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.
I'm using the below way to load the properties file. 我正在使用以下方式加载属性文件。
@Configuration
@PropertySource(value = { "classpath:config.properties" })
public class Configuration {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
Properties are getting resolved and no issues except in one case. 除了一个案例,属性得到解决,没有问题。
I'm using CXF for webservices and the address property is not getting resolved when "${addressVal}"
is used. 我正在使用CXF进行Web服务,并且在使用
"${addressVal}"
时,地址属性无法解析。 All other properties inside the xml are gettign loaded except for "jaxws:client"
. 除了
"jaxws:client"
之外,xml中的所有其他属性都是gettign加载的。
<jaxws:client id="port"
serviceClass="com.service.Myclass"
address="${addressVal}" />
Where is the problem. 问题出在哪儿。 What I'm doing wrong.
我做错了什么。
Problem with servlet context / application context loading ? servlet上下文/应用程序上下文加载的问题?
Please advice. 请指教。
I am having the same problem. 我有同样的问题。 Sadly no solution found yet.
可悲的是还没有找到解决方案。 However, for anyone finding this question, a workaround is using the JaxWsProxyFactoryBean.
但是,对于发现此问题的任何人来说,解决方法是使用JaxWsProxyFactoryBean。
Example: 例:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
<bean id="client" class="demo.spring.service.HelloWorld" factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="demo.spring.service.HelloWorld"/>
<property name="address" value="${some.property.value}"/>
</bean>
It is not as nice, becuase you have to inject the factory, call create() and cast, but at least it works. 它不是很好,因为你必须注入工厂,调用create()和cast,但至少它是有效的。
@Autowired
@Qualifier("clientFactory")
private JaxWsProxyFactoryBean factory;
public void callService() {
HelloWorld helloWorld = (demo.spring.service.HelloWorld)factory.create();
}
You can also add the following to your spring config to create a specific bean, but that did not work for me. 您还可以将以下内容添加到spring配置中以创建特定的bean,但这对我不起作用。 Trying to inject that bean failed, which is why I settled on the method described above.
试图注入该bean失败,这就是为什么我选择了上述方法。
<bean id="client" class="demo.spring.service.HelloWorld" factory-bean="clientFactory" factory-method="create"/>
See also http://cxf.apache.org/docs/writing-a-service-with-spring.html at the bottom of the page 另请参见页面底部的http://cxf.apache.org/docs/writing-a-service-with-spring.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.