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

Maven构建Jar包运行时exec-maven-plugin执行失败求助

Hey there, sorry you're stuck with this frustrating exec-maven-plugin issue—partial error messages like that are always such a tease! Since you’ve already combed through Stack Overflow and GitHub without luck, let’s break this down with targeted checks and fixes that might have slipped through the cracks.

First, Let’s Grab the Critical Missing Details

That error cut off right when it was about to tell us the actual problem. To diagnose this properly, could you share:

  • The full error stack trace (especially the Caused by: section—this is almost always the root cause)
  • The exact Maven command you’re running (e.g., mvn exec:java or mvn exec:java -Dexec.mainClass=com.your.app.Main)
  • The snippet of your pom.xml where the exec-maven-plugin is configured

Targeted Fixes to Try Immediately

Even without the full details, here are some common fixes that resolve this exact plugin failure:

1. Double-Check Your Main Class Configuration

The most common culprit is a missing or incorrect main class definition.

  • If you’re configuring it in pom.xml, make sure the path is fully qualified (including the package):
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.6.0</version>
      <configuration>
        <mainClass>com.your.package.YourActualMainClass</mainClass>
      </configuration>
    </plugin>
    
  • If you’re passing it via the command line, ensure there are no typos:
    mvn exec:java -Dexec.mainClass=com.your.package.YourActualMainClass
    

2. Fix Dependency Scope Issues

If your main class relies on dependencies marked as provided or test, the exec plugin won’t include them in the classpath by default. Add this to your plugin configuration to force including compile-scoped dependencies:

<configuration>
  <mainClass>com.your.package.YourActualMainClass</mainClass>
  <includeScope>compile</includeScope>
</configuration>

3. Clean and Rebuild to Clear Cached Junk

Corrupted class files or cached artifacts often cause weird plugin failures. Run these commands in order:

mvn clean
mvn package
mvn exec:java

4. Upgrade the Exec Plugin Version

Version 1.6.0 is pretty old (released in 2017) and has known compatibility issues with newer Maven (3.8+) and Java (11+) versions. Try upgrading to the latest stable version (as of 2024, that’s 3.1.0):

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>3.1.0</version>
  <configuration>
    <mainClass>com.your.package.YourActualMainClass</mainClass>
  </configuration>
</plugin>

5. Verify Java Version Mismatches

Make sure the Java version Maven is using matches what you compiled your project with. Run mvn -v to check the runtime Java version, then confirm it matches the source and target in your pom.xml:

<properties>
  <maven.compiler.source>17</maven.compiler.source>
  <maven.compiler.target>17</maven.compiler.target>
</properties>

If None of These Work...

Drop the full error log, your plugin configuration, and the command you’re running, and we’ll dig into the exact root cause—whether it’s a missing dependency, permission issue, or something more obscure.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 08:52:52