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

为何无法构建可执行Maven项目?RDF2Vec Jar报主清单属性缺失

Fixing "no main manifest attribute" Error in RDF2Vec Maven Executable JAR

I get it—nothing's more frustrating than a clean Maven build that throws a runtime error because the JVM can't find your entry point. That "no main manifest attribute" error pops up exactly because Maven didn't flag your WalkGenerator class as the executable's starting point in the JAR's manifest.

Why This Happens

When you build a JAR with Maven, the default setup doesn't add a Main-Class attribute to the manifest file. Without this, the JVM has no clue which class to run when you execute java -jar your-rdf2vec.jar, even if your code is perfectly valid.

Your Fix, Explained (And Polished)

Your instinct to update the manifest configuration was spot-on. Here's how to properly implement it in your pom.xml to make walks.WalkGenerator the default main class, while also handling dependency classpaths:

  1. Find (or add) the maven-jar-plugin section inside your <build><plugins> block.
  2. Update its configuration to include the manifest settings with both addClasspath and mainClass:
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>3.3.0</version> <!-- Use the latest stable version -->
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <mainClass>walks.WalkGenerator</mainClass>
          </manifest>
        </archive>
      </configuration>
    </plugin>
  </plugins>
</build>

Quick Tips to Avoid Headaches

  • Double-check the class path: Make sure walks.WalkGenerator is the full, correct package path of your class—no typos here!
  • Rebuild cleanly: After updating the pom.xml, run mvn clean package to generate a fresh JAR with the updated manifest.
  • Verify the manifest: You can peek inside the JAR's META-INF/MANIFEST.MF file to confirm it has lines like:
    Main-Class: walks.WalkGenerator
    Class-Path: [list of your project dependencies]
    

Once you do this, running java -jar your-generated-jar.jar should launch WalkGenerator without that annoying manifest error.

内容的提问来源于stack exchange,提问作者rajiv.v.i

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:20:13