java - Maven 不包括 commons-logging

标签 java maven

我使用 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 (contains the logging), 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/

相关文章:

java - 使用 java -cp 等类路径描述 MANIFEST.MF

noise - 检测并去除噪音文本

java - Hibernate:将子类的实例转换为父类(super class)的实例

java - Hibernate:空集合而不是延迟加载错误

java - 泽西网络服务返回 HTTP 500

java - 无法添加maven依赖

javascript - frontend-maven-plugin 可以使用 node,npm 已经安装了吗?

java - 我们如何通过单个命令行提示符在java代码中执行多个命令?

java - 调试安卓java

java - 用于 Maven 项目的 Netbeans Profiler