【发布时间】:2020-12-10 10:44:03
【问题描述】:
我正在学习在此链接 (https://stackabuse.com/web-scraping-the-java-way/) 上找到的教程,但是当我需要打包项目并运行 jar 时,当我使用 @987654322 时,我在终端中收到“No main manifest attribute error” @。我的 pom.xml 看起来像
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>ApartmentHunt</artifactId>
<version>1.0-SNAPSHOT</version>
<name>ApartmentHunt</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.Maven.plugins</groupId>
<artifactId>Maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.Maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.example.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
App.java 有 main 方法,位于 src/main/java/org.exmaple 中,只包含一个打印语句。代码与教程完全相同,但出现错误。我已经从教程中克隆了 repo,它可以在我的机器上运行,所以我不确定我的项目有什么问题。这是我第一次在项目中使用 maven,我使用了 maven quickstart 原型。
我使用了其他帖子中的各种组装插件,但没有解决我的问题。
【问题讨论】:
标签: java maven intellij-idea jar manifest