java - 进行 maven 配置时 setting.xml 和 pom.xml 出了什么问题
问题描述
我正在尝试探索 maven 作为下载工具,因为这有助于本地缓存以及连接中央/远程存储库。我能够从远程存储库下载工件。但是每次下载到目标位置时,它看起来都不是 .m2 存储库或更新。我相信我在 setting.xml 或 pom.xml 中缺少一些设置。
我打算下载以检查本地存储库中是否已经存在工件可以是 .m2 或预定义的,如果没有,则仅从工件下载。
使用的 Maven 命令:
mvn install pre-integration-test -f pom_download.xml -settings settings.xml -Dmayank=test.txt
输出 :
[INFO] --- wagon-maven-plugin:2.0.0:download-single (download-test-data) @ testdownload ---
[INFO] Downloading: https://artifactory.com/artifactory/test.txt to C:\downloads\test.txt
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.830 s
[INFO] Finished at: 2019-10-04T06:34:40-07:00
[INFO] ------------------------------------------------------------------------
设置.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
| -->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>https</protocol>
<host></host>
<port></port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
<proxy>
<id>optional_1</id>
<active>true</active>
<protocol>http</protocol>
<host></host>
<port></port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
<localRepository>C:\repo_mayank</localRepository>
<servers>
<server>
<id>ubit-artifactory-or</id>
<username>mayank</username>
<password>xxxxx</password>
</server>
</servers>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<id>xxxx</id>
<name>xxxx</name>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>https://artifactory.com/</url>
<layout>default</layout>
</repository>
</repositories>
<mirrors>
<mirror>
<id>our-server-repo</id>
<name>C:\repo_mayank</name>
<url>https://artifactory.com/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Pom.xml
?xml version='1.0' encoding='utf8'?>
<project>
<groupId>com.mayank</groupId>
<artifactId>testdownload</artifactId>
<version>1.0</version>
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<id>download-test-data</id>
<phase>pre-integration-test</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<task>
<echo> Hello World !!!</echo>
</task>
<serverId>artifactory</serverId>
<url>https://artifactory.com</url>
<fromFile>${mayank}</fromFile>
<toDir>C:\downloads</toDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<mayank> hello </mayank>
</properties>
</project>
解决方案
看起来 maven wagon 插件根本不使用 maven 缓存。如果要下载链接到项目的工件,可以使用 maven 依赖插件并使用 copy-dependencies 目标。如果您只想复制一些工件,请使用复制目标。更多信息:http ://maven.apache.org/plugins/maven-dependency-plugin/无论哪种方式,您都必须在 pom 中指定您想要的内容。
推荐阅读
- c++ - 无返回 lambda 奇怪的行为
- pyspark - Pyspark 流媒体
- visual-studio-code - 如何将 KDiff3 配置为 VSCode 编辑器的合并工具
- git - 詹金斯工作区有时会被删除
- c# - C# Winforms - 当鼠标不在文本框上时在文本框上显示工具提示
- java - 在 H2 [SPRING-BOOT] 上使用整数而不是 NamedParameterJDBCTemplate 时的未知数据类型
- ios - 如何在swift中为stackview中包含的标签提供动态高度
- c++ - c++ 取消引用指向迭代器的指针
- python-3.x - 如何使列中的大数字看起来可读(如 100B)
- java - 当我不使用绿色播放按钮运行应用程序时出现错误