abi*_*ter 8 java wsdl2java build.gradle
尝试在我的应用程序中添加 apache-cxf 包。但是在运行应用程序时出现以下错误无法实例化 [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping]:工厂方法“payloadRootAnnotationMethodEndpointMapping”抛出异常;嵌套异常是 java.lang.ExceptionInInitializerError
这是由引起的:java.lang.IllegalArgumentException:不支持:http://javax.xml.XMLConstants/property/accessExternalDTD
尝试在任务中添加以下属性
wsdl2java {
System.setProperty('javax.xml.accessExternalSchema', 'all')
System.setProperty('javax.xml.accessExternalDTD','all')
generatedWsdlDir = file("src/main/generated-sources/") // target directory for generated source code
wsdlsToGenerate = [ // 2d-array of wsdls and cxf-parameters
['src/main/resources/xsd/wsdl/***.wsdl'],
]
Run Code Online (Sandbox Code Playgroud)
}
added the dependency as
compile group: 'org.apache.cxf', name: 'cxf-bundle', version: '2.4.2'
Run Code Online (Sandbox Code Playgroud)
出现以下错误
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping]: Factory method 'payloadRootAnnotationMethodEndpointMapping' threw exception; nested exception is java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:576) ~[xalan-2.7.1.jar:?]
Run Code Online (Sandbox Code Playgroud)
在检查依赖树时,看到 Xalan 的多个版本。这使得依赖冲突。通过添加以下行解决错误
compile (group: 'org.apache.cxf', name: 'cxf-bundle', version: '2.4.2') {
exclude module: 'xalan'
}
Run Code Online (Sandbox Code Playgroud)