我使用 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/