我已经使用Gradle插件基于WSDL生成Java文件。当我使用任何IDE(例如Intellij,Eclipse等)在本地进行开发时,一切正常,并且WS请求顺利通过。
但是,当我尝试将其作为由bootJar方法生成的可执行jar运行时,一旦尝试与同一WS交互,就会出现以下错误:
org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 69 counts of IllegalAnnotationExceptions
There's no ObjectFactory with an @XmlElementDecl for the element {UrgTech/Service/Data/DataContract}Data.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement urgtech.service.data.datacontract.File.data
at urgtech.service.data.datacontract.File
at protected java.util.List urgtech.service.data.datacontract.Files.file
at urgtech.service.data.datacontract.Files
at public javax.xml.bind.JAXBElement urgtech.service.data.datacontract.operation.ObjectFactory.createCreateQuoteFiles(urgtech.service.data.datacontract.Files)
at urgtech.service.data.datacontract.operation.ObjectFactory
at protected javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.CreateQuote.data
at service.urgtech.supplierapi.service.CreateQuote
at public service.urgtech.supplierapi.service.CreateQuote service.urgtech.supplierapi.service.ObjectFactory.createCreateQuote()
at service.urgtech.supplierapi.service.ObjectFactory
at protected javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.ReadAssignments.authentication
at service.urgtech.supplierapi.service.ReadAssignments
There's no ObjectFactory with an @XmlElementDecl for the element {UrgTech/Service/Data/DataContract/Response}Message.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement urgtech.service.data.datacontract.response.RequestStatus.message
at urgtech.service.data.datacontract.response.RequestStatus
at public javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.ObjectFactory.createCreateQuoteResponseCreateQuoteResult(urgtech.service.data.datacontract.response.RequestStatus)
at service.urgtech.supplierapi.service.ObjectFactory
at protected javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.ReadAssignments.authentication
at service.urgtech.supplierapi.service.ReadAssignments
There's no ObjectFactory with an @XmlElementDecl for the element {UrgTech/Service/Data/DataContract/Response}CallerName.
this problem is related to the following location:
到目前为止,我试图做的是:
这是我的build.gradle:
configurations {
jaxb
}
buildscript {
ext {
springBootVersion = "${springBootVersion}"
}
repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
classpath('no.nils:wsdl2java:0.10')
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'docker'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'no.nils.wsdl2java'
group = 'com.urbanise.middleware'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
maven {
mavenLocal()
jcenter()
}
}
bootJar {
baseName = 'urgtech-plaza'
version = '0.0.1-SNAPSHOT'
from genJaxb.classesDir
dependsOn wsdl2java
}
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web-services'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail'
implementation group: 'org.springframework', name: 'spring-orm'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-aws-autoconfigure'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-aws-messaging'
implementation group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: "${springSecurityOAuth2Version}"
implementation group: 'org.springframework.security.oauth', name: 'spring-security-oauth2'
implementation group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"
implementation group: 'org.apache.commons', name: 'commons-lang3', version: "${apacheCommonsVersion}"
implementation group: 'wsdl4j', name: 'wsdl4j', version: "${wsdl4JVersion}"
implementation group: 'org.postgresql', name: 'postgresql', version: "${postgresqlVersion}"
implementation group: 'org.flywaydb', name: 'flyway-core', version: "${flywayVersion}"
implementation group: 'com.google.guava', name: 'guava', version: "${guavaVersion}"
implementation group: 'org.apache.commons', name: 'commons-text', version: "${apacheCommonsTextVersion}"
implementation group: 'commons-validator', name: 'commons-validator', version: "${apacheValidationVersion}"
implementation group: 'org.apache.camel', name: 'camel-spring-boot', version: "${camelVersion}"
implementation group: 'org.apache.camel', name: 'camel-jackson', version: "${camelVersion}"
implementation group: 'org.apache.camel', name: 'camel-metrics', version: "${camelVersion}"
implementation group: 'io.hawt', name: 'hawtio-springboot', version: "${hawtIoVersion}"
implementation group: 'io.hawt', name: 'hawtio-web', version: "${hawtIoWebVersion}"
implementation group: 'io.hawt', name: 'hawtio-core', version: "${hawtIoVersion}"
implementation group: 'io.hawt', name: 'hawtio-system', version: "${hawtIoVersion}"
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda'
implementation group: 'org.freemarker', name: 'freemarker', version: "${freemakerVersion}"
implementation group: 'com.amazonaws', name: 'aws-java-sdk-ses', version: "${awsSDKSESVersion}"
compileOnly group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
jaxb group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: "${jaxbxjcVersion}"
implementation(files(genJaxb.classesDir).builtBy(genJaxb))
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
applyMavenExclusions false
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.SR2'
}
}
wsdl2java {
generatedWsdlDir = file("${projectDir}/src/main/java/com/urbanise/middleware/urgtechplaza/generated")
wsdlsToGenerate = [
['-autoNameResolution', 'src/main/resources/urgtech.wsdl']
]
wsdlDir = file("$projectDir/src/main/resources")
locale = Locale.ENGLISH
stabilizeAndMergeObjectFactory = true
}
wsdl2javaExt {
cxfVersion = "3.3.2"
}
compileJava.dependsOn wsdl2java
sourceSets {
main.java.srcDirs += [wsdl2java.generatedWsdlDir]
}
和gradle.properties:
#Libraries versions
springBootVersion=2.0.6.RELEASE
elasticMqVersion=0.13.8
camelVersion=2.22.1
guavaVersion=27.0-jre
postgreSQLDriverVersion=42.2.2
hawtIoVersion=2.3.0
hawtIoWebVersion=1.5.11
lombokVersion=1.18.4
hibernateVersion=5.3.2.Final
springBootJPAVersion=2.0.3.RELEASE
apacheCommonsTextVersion=1.4
apacheValidationVersion=1.6
flywayVersion=5.0.7
springSecurityOAuth2Version=2.3.4.RELEASE
postgresqlVersion=42.2.2
apacheCommonsVersion=3.8.1
wsdl4JVersion=1.6.3
jaxbxjcVersion=2.3.2
springCloudAwsVersion=2.0.1.RELEASE]
jaywayJsonPath=2.4.0
plazaExternalModelVersion=1.1.20
urgtechWSDLModelVersion=1.0.0
awsSDKSESVersion=1.11.490
freemakerVersion=2.3.28
#TEST DEPENDENCIES
randomBeansVersion=3.7.0
mockitoVersion=2.0.2-beta
我使用的精确gradle插件可以在这里找到:https://plugins.gradle.org/plugin/no.nils.wsdl2java,但是我不认为问题出在这里,如果是这样的话,它就不会在本地工作。 它的包装方式一定有问题,但是我对gradle的了解不是那么熟练,所以我真的不知道在哪里看。任何帮助将不胜感激。