SpringBoot+CXF发布Webservice时报错:counts of IllegalAnnotationExceptions

由于项目需要,与生成环境的其他系统对接,对方采用的是Webservice的接口方式,为了验证我们自己开发的对接是否正常,因此,自己写了对应的接口来验证,结果发布Webservice的时候报错:

Caused by: org.apache.cxf.service.factory.ServiceConstructionException: null
	at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:361)
	at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:87)
	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:469)
	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:693)
	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:529)
	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:262)
	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
	at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
	at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460)
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338)
	... 38 common frames omitted
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
	at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:76)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:450)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:282)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:109)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1142)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:144)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
	at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345)
	at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:343)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:343)
	at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:245)
	at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:500)
	at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:359)
	... 49 common frames omitted

看到counts of IllegalAnnotationExceptions的错误,下意识的理解为注解有问题,结果排查了一圈,没发现任何问题;百度一圈,命名空间重复之类的,反正都对不上我的问题。后来无意中发现接口用到的实体类的属性声明为public的,以为只是写错了,顺手就修改为习惯的private了,结果再次发布Webservice,居然没错了,居然还有这样的坑!!!赶快记下来。

你可能感兴趣的:(java,java,CXF,Webservice,报错)