写的工具maven工程,写好入口类和main方法后,在pom.xml文件,要加上mainclass入口类(并且将依赖的lib包一起打进去,同时解决签名冲突)

写的工具maven工程,写好入口类和main方法后,在pom.xml文件,要加上mainclass入口类(并且将依赖的lib包一起打进去,同时解决签名冲突)

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.4.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.yourcompany.MainClass</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

  

posted @ 2026-01-16 15:19  技术虫  阅读(1)  评论(0)    收藏  举报