When Hadoop integration SpringBoot, appear to solve the problem of the jar package conflicts

When Hadoop integration SpringBoot, appear to solve the problem of the jar package conflicts

2020-01-03 (Fri sunny day)

development tools:

IDEA .2019-2
Hadoop 2.9.2
Maven
SpringBoot 1.5.8
JDK 1.8

Problem Description

The project requirements and integration springboot hadoop systems, to complete a simple personal file storage system, the effect is as follows:
D pictures inserted here described in
However, when the integration, and springboot hadoop, project start, given:
a java.lang.IllegalStateException: Detected both log4j-over-SLF4J .jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError.
Here Insert Picture Description

Causes

By the error message in the log, it would presumably be caused jar package conflicts. A plurality slf4j-log4j12.jar like.
Later, through access to relevant blog, found that one reason there are:
the servlet-API in the jar hadoop-common package, log4j, slf4j-log4j12, jaxb -impl four related dependence
and the "hadoop-client "the jar package" servlet-api, log4j, slf4j -log4j12, jsr305, jsp-api " the five of dependencies
cause dependence conflicts with the tomcat-embed-jasper.

Because bloggers have their own projects using log4j, the need to remove all of which depend on log4j, ladies and gentlemen project may not need to remove these dependencies, please, as the case may be.

Solution

Conflict in the jar to remove excess related dependence.

 <!--hadoop公共依赖-->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>${hadoop.version}</version>
            <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.servlet</groupId>
                        <artifactId>servlet-api</artifactId>
                    </exclusion>
                <exclusion>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--hadoop client 依赖-->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <version>${hadoop.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.code.findbugs</groupId>
                    <artifactId>jsr305</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>jsp-api</artifactId>
                    <groupId>javax.servlet.jsp</groupId>
                </exclusion>
            </exclusions>

        </dependency>

Follow-up question:

Follow the steps mentioned above to solve, find the project can start. However, when the page is accessed, an error once again.
Here Insert Picture Description
javax.el.ExpressionFactory.newInstance () Ljavax / el / ExpressionFactory
; the wrong type, can be roughly analysis, the reason is because of the lack of resolve page. So, once again refer to the relevant blog post, we still need to find a jsp's import dependence

 		<dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

So far, the project can be a normal visit.

Published 32 original articles · won praise 1 · views 1182

Guess you like

Origin blog.csdn.net/ASYMUXUE/article/details/103820055