春季启动:org.codehaus.jackson.map.exc.UnrecognizedPropertyException:WebSphere中无法识别的字段“ XX”

时间:2019-02-13 11:16:48

标签: java spring-boot jackson websphere-liberty

我有一个执行反向Swagger Yaml的spring boot应用程序:

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
        <execution>
            <id>generate-swagger-java</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${basedir}/src/main/resources/swagger/cview.yaml</inputSpec>
                <apiPackage>client.api</apiPackage>
                <modelPackage>client.model</modelPackage>
                <output>${project.build.directory}/generated-sources</output>
                <language>java</language>
                <configOptions>
                    <dateLibrary>java8</dateLibrary>
                    <library>jersey2</library>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

与主类一起运行,效果很好

public static void main(final String[] args) {
 SpringApplication.run(SpringBootApp.class, args);
}

但是当我在SpringBootServletInitializer上使用WebSphere libertyCore运行它时,它会卡住,并在尝试调用Web服务时给我这些错误:

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "id_entite" (Class client.model.GaEj), not marked as ignorable

Problem with reading the data, class client.model.SearchResultGaEj, ContentType: application/json;charset=UTF-8

问题是我对org.codehaus.jackson.*没有任何依赖

我只使用com.fasterxml.jackson.datatype

1 个答案:

答案 0 :(得分:0)

默认情况下,players使用assume_unique=Truereference)。 WebSphere使用两个Class-loader modesCodehaus JacksonWebSphere。您需要确保应用程序使用FasterXML中的Parent first,而不是Parent last中的JacksonCodehause没有自己的托管库,但是Spring BootWebSphere,它提供了许多已连接的库,因此您无需为它们提供应用程序。

请参阅:

  1. Catch JsonProcessingException from Jackson in Websphere Liberty
  2. Change Default JSON Provider on WebSphere Application Server
  3. Override Jackson Object Mapper properties on Websphere 8.5.5 using Apache Wink
  4. How to change Jackson version in JAX-RS app (WebSphere Liberty)