0

问题:

我在 SpringBoot 应用程序中创建了一个端点,当我用邮递员点击端点时,我得到了所有“列表”数据类型的重复节点。示例“类别关系”

输出

<categoryRelationships>
            <categoryRelationship>
                <categoryRelationship>
                    <parentCategoryId>343535</parentCategoryId>
                    <childCategoryId>64565</childCategoryId>
                    <startDate>2017-09-21T18:33:01.649+0000</startDate>
                    <categoryRelationshipKey>
                        <idPk>4563</idPk>
                        <lastUpdateDate>2017-09-21T18:33:01.765+0000</lastUpdateDate>
                        <lastUpdateUser>somename</lastUpdateUser>
                    </categoryRelationshipKey>
                </categoryRelationship>
            </categoryRelationship>
        </categoryRelationships>

我的 Gradle 依赖项:
实现 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2'
实现 'org.glassfish.jaxb:jaxb-runtime:2.3.3'
运行时 'com.sun.xml.bind: jaxb-impl:3.0.0'
实现'javax.xml.bind:jaxb-api:2.3.1'


Spring 日志: 22:45:10.974 调试 javax.xml.bind - 搜索 jaxb.properties 22:45:10.975 调试 javax.xml.bind - 检查系统属性 javax.xml.bind.JAXBContextFactory 22:45:10.975 调试 javax.xml .bind - 未找到 22:45:10.975 调试 javax.xml.bind - 检查系统属性 javax.xml.bind.context.factory 22:45:10.975 调试 javax.xml.bind - 未找到 22:45:10.975 调试 javax .xml.bind - 检查系统属性 javax.xml.bind.JAXBContext 22:45:10.976 调试 javax.xml.bind - 未找到 22:45:10.981 调试 javax.xml.bind - 使用的 ServiceProvider 加载工具;返回对象 [com.sun.xml.bind.v2.JAXBContextFactory] ​​22:45:10.987 调试 csxbv2.ContextFactory -属性 com.sun.xml.bind.XmlAccessorFactory 未激活。 使用 JAXB 的实现 22:45:11.293 调试 csxbv2.util.XmlFactory - SAXParserFactory 实例:com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl@363e0b6c 22:45:11.330 调试 oswsmmaRequestResponseBodyMethodProcessor - 使用 'application/xml',给定 [application/xml] 并支持 [application/xml]

我尝试使用 jaxb 手动转换并删除重复节点并给我正确的响应。

为什么spring在响应时使用“com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl”作为默认xml转换器?我怀疑这个解析器的问题。为什么它说 Property com.sun.xml.bind.XmlAccessorFactoryis not active?

4

0 回答 0