小编chr*_*ern的帖子

JAXBException:不是类的有效属性

我们有一个需要使用外部Web服务的应用程序.为此,我们使用cxf-codegen-plugin插件提供的wsdl2java目标,通过Maven从WSDL生成了一组Java工件.

在应用程序中,我们希望将端点设置为在运行时用于Web服务调用(以满足测试环境中的不同Web服务端点URL),因此编写了一些代码,如下所示为我们执行此操作:

private <T> T createServiceObject(final Class<T> p_seiClass) throws MalformedURLException {

        final Service serviceFactory = Service.create(new URL(wsdlLocation), new QName(targetNamespace, serviceName));
        final T service = serviceFactory.getPort(p_seiClass);
        ((BindingProvider) service).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "endpoint");

        return service;
    }
Run Code Online (Sandbox Code Playgroud)

当代码运行时,它在serviceFactory.getPort行上失败,并带有以下execption:

javax.xml.ws.WebServiceException: class ZZZ.YYYwebservice.v5.types.ProcessUIRequestResponse do not have a property of the name ProcessUIRequestResult
    at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.<init>(ResponseBuilder.java:512)
    at com.sun.xml.internal.ws.client.sei.SEIMethodHandler.buildResponseBuilder(SEIMethodHandler.java:172)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.<init>(SyncMethodHandler.java:86)
    at com.sun.xml.internal.ws.client.sei.SEIStub.<init>(SEIStub.java:83)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:641)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:344)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:326)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:364)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:368)
    at javax.xml.ws.Service.getPort(Service.java:172)
    at com.XXX.XXX.XXX.YYY.integration.facade.jaxws.ProcessUIRequestFacadeJaxws.createServiceObject(ProcessUIRequestFacadeJaxws.java:53)
    at com.XXX.XXX.XXX.YYY.integration.facade.jaxws.ProcessUIRequestFacadeJaxws.processUIRequest(ProcessUIRequestFacadeJaxws.java:39)
    at com.XXX.XXX.XXX.YYY.integration.facade.jaxws.ProcessUIRequestFacadeJaxwsTest.test(ProcessUIRequestFacadeJaxwsTest.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at …
Run Code Online (Sandbox Code Playgroud)

java cxf jax-ws jaxb webservice-client

9
推荐指数
1
解决办法
1万
查看次数

Spring Boot命令行属性不覆盖application.properties中定义的属性

我创建了一个使用旧库的Spring Boot应用程序.这个遗留库在XML中定义了许多Spring Beans.其中一个将属性值作为构造函数参数:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <bean id="myBean" class="com.em.MyBean">
        <constructor-arg name="url" value="${my.url}"/>
    </bean>
</beans>
Run Code Online (Sandbox Code Playgroud)

在我的Spring Boot应用程序中,我有一个application.properties定义此属性的方法如下:

my.url=http://localhost:8080
Run Code Online (Sandbox Code Playgroud)

我使用Maven Spring Boot插件在本地运行我的应用程序,如下所示:

mvn spring-boot:run
Run Code Online (Sandbox Code Playgroud)

并且属性值按预期注入bean中.

如果我尝试my.url在命令行上覆盖属性,如下所示:

mvn spring-boot:run -Dmy.url=http://www.override.net
Run Code Online (Sandbox Code Playgroud)

不使用overriden值,而是application.properties使用inside值.

根据Spring Boot文档,命令行中的值应作为第一优先级:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config .html.这似乎不是这种情况,因为如果我application.properties从那时删除属性,则使用命令行传入的值,因此不会完全忽略命令行值的情况.看起来该application.properties值会覆盖命令行值.

有没有人对于发生了什么有任何想法?

java spring spring-boot spring-properties spring-boot-maven-plugin

3
推荐指数
2
解决办法
5970
查看次数