You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ社区版Maven项目插件未找到 无法构建可执行Jar如何解决

问题解决方案

你遇到的插件找不到报错的核心原因是pom.xml中所有插件都未指定<version>标签,Maven无法定位到对应版本的插件包,才会出现未找到的错误。

第一步:修正pom.xml配置

给所有插件补充稳定可用的版本号即可,注意maven-shade-plugin和maven-assembly-plugin功能重叠,选一个使用即可,同时配置可能引发冲突。修正后的配置参考如下:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>替换为你的实际主类全路径</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.3.0</version>
            <configuration>
                <finalName>ServiceCreate</finalName>
                <appendAssemblyId>false</appendAssemblyId>
                <archive>
                    <manifest>
                        <mainClass>com.svt.optimoo.App</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRef>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

第二步:补充版本后依然报错的排查方案

  • 检查Maven镜像源:打开Mac系统下~/.m2/settings.xml配置文件,确认配置了国内可用的镜像源,推荐阿里云镜像,配置片段如下:
<mirrors>
    <mirror>
        <id>aliyunmaven</id>
        <mirrorOf>*</mirrorOf>
        <name>阿里云公共仓库</name>
        <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
</mirrors>
  • 强制更新Maven依赖:在IDEA的Maven面板点击执行命令按钮,输入mvn clean compile -U执行,强制拉取缺失的插件包。
  • 清理损坏的本地缓存:进入~/.m2/repository/org/apache/maven/plugins路径,删除对应报错插件的文件夹,再重新加载Maven项目。

无需配置插件的替代打包方案

可以直接使用IDEA自带的功能生成可执行Jar,操作步骤如下:

  1. 打开File > Project Structure > Artifacts
  2. 点击+号,选择JAR > From modules with dependencies
  3. 选择你的项目模块和主类,勾选copy to the output directory and link via manifest,点击确认
  4. 回到主界面点击Build > Build Artifacts,选择刚创建的Jar配置点击Build即可,生成的可执行Jar会存放在项目out/artifacts目录下。

内容的提问来源于stack exchange,提问作者Sean

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.17 12:06:00