Solve the conflict between the jackson package of elasticsearch and the jackson package in jboss (wildfly)

Generally, when a java web project is released on jboss for the first time, it will encounter the jackson package of elasticsearch and the jackson package of jboss due to version conflict, resulting in the release failure.

My error message was probably like this

ERROR [io.undertow.request] (default task-5) UT005023: Exception handling request to /cmall-admin-web/order/queryForPage.htm: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.common.xcontent.smile.SmileXContent

In this case, you can try to modify and publish according to the following methods:

1. First create a new jboss-deployment-structure.xml file in the WEB-INF directory of the web project

<?xml version="1.0" encoding="UTF-8" ?>
<jboss-deployment-structure>
    <deployment>
        <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
        <!-- The main function is to output the log of the application to your own set directory, instead of outputting it to wildfly's server.log -->
        <exclusions>
            <module name="org.slf4j" />
            <module name="org.slf4j.impl" />
            
            <!-- Solve the conflict between es jackson package and jackson in other jar packages-->
            <module name="com.fasterxml"/>
            <module name = "org.jboss.resteasy.resteasy-jackson2-provider" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

 2. Add the jackson-core jar package to pom.xml

<!-- Solve the conflict between es jackson package and jackson in other jar packages-->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.6.6</version>
</dependency>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326461679&siteId=291194637