idea普通maven项目打包

在pom文件加上这个,自动配置主类信息

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>
                                shade
                            </goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>主类位置main类位置</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

然后是用maven工具

​​

如果是什么

​Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory​报错就是没在pom加入对应的依赖

​​


idea普通maven项目打包
http://www.404np.com:8080/archives/1726044701405
作者
北冥有鱼,其名为鲲
发布于
2024年09月11日
更新于
2024年09月11日
许可协议