Gradle:由 gradle bootJar 任务创建的 jar 不起作用
Posted
技术标签:
【中文标题】Gradle:由 gradle bootJar 任务创建的 jar 不起作用【英文标题】:Gradle: created jar by gradle bootJar task is not working 【发布时间】:2019-12-13 03:41:16 【问题描述】:由 gradle 任务 bootJar 创建的 jar 不起作用。获取 javax.xml.bind.JAXBException。但是使用 gradle bootRun 或通过 IDEA 一切正常
Caused by: javax.xml.bind.JAXBException: class com.xxx.PayOrderStatisticsGetRequest nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:593) ~[jaxb-impl-2.2.6.jar!/:2.2.6]
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482) ~[jaxb-impl-2.2.6.jar!/:2.2.6]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323) ~[jaxb-impl-2.2.6.jar!/:2.2.6]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251) ~[jaxb-impl-2.2.6.jar!/:2.2.6]
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95) ~[na:1.8.0_221]
at org.apache.axis2.datasource.jaxb.JAXBDSContext$1.run(JAXBDSContext.java:477) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axis2.datasource.jaxb.JAXBDSContext$1.run(JAXBDSContext.java:462) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:76) ~[axis2-kernel-1.7.9.jar!/:1.7.9]
at org.apache.axis2.datasource.jaxb.JAXBDSContext.marshalByElement(JAXBDSContext.java:462) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axis2.datasource.jaxb.JAXBDSContext.marshal(JAXBDSContext.java:422) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._outputFromBO(JAXBBlockImpl.java:175) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axis2.jaxws.message.impl.BlockImpl.outputTo(BlockImpl.java:371) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axis2.jaxws.message.impl.BlockImpl.serialize(BlockImpl.java:295) ~[axis2-jaxws-1.7.9.jar!/:1.7.9]
at org.apache.axiom.om.impl.common.serializer.push.stax.StAXSerializer.serializePushOMDataSource(StAXSerializer.java:53) ~[axiom-dom-1.2.21.jar!/:na]
at org.apache.axiom.om.impl.common.serializer.push.Serializer.serialize(Serializer.java:293) ~[axiom-dom-1.2.21.jar!/:na]
【问题讨论】:
PayOrderStatisticsGetRequest 这个类的代码是什么 @ApiModel(value = "PayOrderStatisticsGetRequest") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "PayOrderStatisticsGetRequest") 公共类 PayOrderStatisticsGetRequest 【参考方案1】:@ApiModel(value = "PayOrderStatisticsGetRequest", description = "Запрос на получение сводки по количеству ПП на подпись и отправку")
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "")
@XmlRootElement(name = "PayOrderStatisticsGetRequest")
@XmlSeeAlso(PayOrderStatisticsGetRequest.class) //add this and try
public class PayOrderStatisticsGetRequest
参考javax.xml.bind.JAXBException: Class *** nor any of its super class is known to this context
【讨论】:
使用 bootRun 我在 JAXBContext 中看到了这个模型,但是使用 bootJar 没有以上是关于Gradle:由 gradle bootJar 任务创建的 jar 不起作用的主要内容,如果未能解决你的问题,请参考以下文章
如何让 Teamcity Artifactory 插件在 Gradle 中调用 bootJar 而不是 Jar?
使用 gradle bootJar 而不是 jar 任务并在 Jenkins 中构建失败
如何使用 Spring Boot“bootJar”插件创建 gradle 任务以生成爆炸性战争?
Gradle kotlin Springboot多模块导致无法引用kotlin的类文件(BootJar)