java - 如何为 maven-jar 插件指定一个新位置以删除所需的库
问题描述
我正在尝试使用 Maven 构建我的项目,并且库一直被删除到 /target。我能够使用outputDirectory
标签为我的项目的 jar 选择一个新的输出目录。
如何为所需的 jar 文件选择目录来运行我的程序?我可以指定要保存哪些?
编辑(pom文件):
<?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>CarlosRoma</groupId>
<artifactId>TestTools</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!--Main class of the project here-->
<mainClass>TestToolClasses.TestTool</mainClass>
</manifest>
</archive>
<outputDirectory>C:\Users\Roma\Desktop\TestTool</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<name>TestTool</name>
</project>
提前致谢!
解决方案
推荐阅读
- python - python展平一个数组
- ruby - 如何获得 Ruby 解释器调用栈?
- javascript - 我不知道为什么结束括号和分号。一直显示红色。我确定我的代码是正确的
- node.js - 所有没有全局安装的npm包都不能直接执行
- python - 如何根据标题名称移动 csv 中的数据并将其移动到同一列中?
- ray - 是否可以肯定地将一名工作人员分配给集群中的一台主机?
- asciidoc - 如何修复“内联代码中的链接突出显示”?
- android - 启动获取请求时 Kotlin 应用程序崩溃
- wso2 - WSO2 EI For循环遍历Json数组
- c# - 如何在 C# 中获取空数组的元素类型?