我使用maven,但是在构建项目时有一个NoClassFound,因为commons-logging不在最终的jar中构建。

[INFO] Excluding commons-logging:commons-logging:jar:1.1.1 from the shaded
jar.
[INFO] Including redis.clients:jedis:jar:2.9.0 in the shaded jar.
[INFO] Including org.apache.commons:commons-pool2:jar:2.4.2 in the shaded
jar.
[INFO] Including org.apache.commons:commons-dbcp2:jar:2.1.1 in the shaded
jar.
[INFO] Including mysql:mysql-connector-java:jar:5.1.38 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.


我的pom:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.1</version>
        <configuration>
            <artifactSet>
                <includes>
                    <include>redis.clients</include>
                    <include>org.apache.commons</include>
                    <include>org.apache.commons.logging</include>
                    <include>mysql</include>
                </includes>
            </artifactSet>
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
            </execution>
        </executions>
    </plugin>


Y具有多个依赖项,具有:jedis,commons-dbcp2(包含日志记录),mysql-connector-java

最佳答案

您包括了groupIds

<include>redis.clients</include>
<include>org.apache.commons</include>
<include>org.apache.commons.logging</include>
<include>mysql</include>


因此jar不包含groupId commons-logging

关于java - Maven不包括Commons-Logging,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46969386/

10-12 13:59