首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在maven项目中jar文件中没有主清单属性错误

在maven项目中jar文件中没有主清单属性错误
EN

Stack Overflow用户
提问于 2022-07-27 19:31:33
回答 1查看 213关注 0票数 0

我目前正在java中构建一个不和谐的机器人,但是当我试图导出.jar文件并运行它时,它会出现以下错误:“在name.jar中没有主清单属性”,我按照许多答案来修复这个问题,调整了pom.xml文件,但是它仍然存在这个问题。我的pom档案:

代码语言:javascript
复制
    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <build>
        <plugins>
            <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>3.0.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <release>17</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.furetto126.furettobot.FurettoBot</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.furetto126.furettobot</groupId>
    <artifactId>FurettoBot</artifactId>
    <version>1.1</version>

    <properties>
        <maven.compiler.release>17</maven.compiler.release>
    </properties>

    <repositories>
        <repository>
            <id>dv8tion</id>
            <name>m2-dv8tion</name>
            <url>https://m2.dv8tion.net/releases</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>net.dv8tion</groupId>
            <artifactId>JDA</artifactId>
            <version>5.0.0-alpha.12</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.sedmelluq</groupId>
            <artifactId>lavaplayer</artifactId>
            <version>1.3.77</version>
        </dependency>
    </dependencies>
</project>

我对使用maven非常陌生,所以问题可能很明显,但我在网上找不到任何解决方案

EN

回答 1

Stack Overflow用户

发布于 2022-07-27 22:12:45

你试过下面的代码了吗?

代码语言:javascript
复制
<plugin>
  <!-- Build an executable JAR -->
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>3.1.0</version>
  <configuration>
    <archive>
      <manifest>
        <addClasspath>true</addClasspath>
        <classpathPrefix>lib/</classpathPrefix>
        <mainClass>com.mypackage.MyClass</mainClass>
      </manifest>
    </archive>
  </configuration>
</plugin>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73143677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档