maven项目打jar包时指定主类,并将依赖也打进来_maven 指定主类_futurezhhy的博客-CSDN博客

在pom文件里加入下面代码:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</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.chinaums.Service</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

原网址: 访问
创建于: 2023-06-13 12:27:32
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论