我正在尝试制作包含项目中所有依赖项的 jar 文件。我正在使用 IntelliJ。
我尝试了两种方法。
在 IntelliJ 右上角的 Maven 窗口中,我单击了下面的 pom.xml 中的“clean”和“package”。
但它不包含任何依赖项。
我在 window 中使用 IntelliJ,所以我无法点击下面的 CLI 链接。我正在使用 IntelliJ 右上部分的 GUI maven 窗口。
如何使用 Maven 创建具有依赖项的可执行 JAR?
我单击了下面的链接中的“构建-构建工件 - 构建”。 如何正确从 IntelliJ 构建 jar? 它似乎包含其他库,但由于某种原因我无法执行该文件。所以,请让我使用 maven window,而不是 build-artifact。
<?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>secret.App</groupId>
<artifactId>mt</artifactId>
<version>1.0-SNAPSHOT</version>
<name>mt</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.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> …Run Code Online (Sandbox Code Playgroud)