简体   繁体   English

Maven - 如何删除阴影 .jar 的 module-info.class 警告?

[英]Maven - How to remove module-info.class warning for shaded .jar?

So here's my problem...所以这是我的问题...

I'm packaging a Spring Boot app into an uber jar using the maven-shade plugin.我正在使用 maven-shade 插件将 Spring Boot 应用程序打包到 uber jar 中。 Simple, right?很简单吧? Well, it is except as of recently I'm getting the following warning at the end of mvn clean package :好吧,除了最近我在mvn clean package结束时收到以下警告:

[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.

It's not actually breaking anything but I'm a perfectionist and this is driving me nuts?这实际上并没有破坏任何东西,但我是一个完美主义者,这让我发疯了吗? How do I get rid of it?我该如何摆脱它? I've tried many things but no success.我尝试了很多东西,但没有成功。

Please help :(请帮忙 :(

As referenced in a comment, filtering out the file in the shade plugin seems to work fine for me.正如评论中所引用的,过滤掉阴影插件中的文件对我来说似乎很好。

Here's what my maven-shade-plugin config looks like:这是我的maven-shade-plugin配置的样子:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>module-info.class</exclude>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

The key line is the <exclude>module-info.class</exclude> .关键是<exclude>module-info.class</exclude> The filter excludes that file whenever it sees it, in any artifact ( *:* = any artifact).过滤器在任何工件( *:* = 任何工件)中看到它时都会排除该文件。 (The other three excludes I use to get rid of bugs with signature files in dependencies) (其他三个排除我用来摆脱依赖项中签名文件的错误)

I haven't noticed any unwanted side effects from doing this, and the warning is now gone!我没有注意到这样做有任何不需要的副作用,现在警告消失了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么Maven shade插件删除module-info.class? - Why does Maven shade plugin remove module-info.class? 如何防止 proguard 从输出 jar 中删除“module-info.class”? - How to prevent proguard from removing “module-info.class” from the output jar? 我收到此错误严重:无法处理来自 Jar 的 Jar 条目 [module-info.class] - I am getting this error SEVERE: Unable to process Jar entry [module-info.class] from Jar 我收到此错误无法处理来自 jar 的 Jar 条目 [module-info.class] - I am getting this error Unable to process Jar entry [module-info.class] from jar 无法索引类module-info.class - Could not index class module-info.class java.lang.RuntimeException:从 jar 扫描入口模块信息.class 时出错 - java.lang.RuntimeException: Error scanning entry module-info.class from jar 严重:无法在 Tomcat 7 &amp;&amp; Java 8 中处理 Jar 条目 [module-info.class] - SEVERE: Unable to process Jar entry [module-info.class] in Tomcat 7 && Java 8 jlink找不到模块info.class - jlink not finding module-info.class maven-bundle-plugin 失败并显示“无效的类文件 module-info.class” - maven-bundle-plugin fails with “Invalid class file module-info.class” 在jdk 9中打包为jar时出现--module-version或--hash-dependencies之一而没有module-info.class错误 - One of --module-version or --hash-dependencies without module-info.class error getting while packaging as jar in jdk 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM