gpt4 book ai didi

maven - 如何在 Maven 中仅部署 zip Artifact

转载 作者:行者123 更新时间:2023-12-04 11:51:44 25 4
gpt4 key购买 nike

我使用下面的描述符和 pom 文件在 maven 中做了一些 zip 打包。但是在 maven 中,默认情况下它在目标文件夹中创建了 jar 和 zip。现在我只想在我使用 deploy:deploy-file 插件的地方部署 zip 内容。但它没有部署而是显示错误。不确定标签有什么问题以及应该如何解决。

pom文件:

<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>com.wyndhamvo.prototype.dbscripts</groupId>
<artifactId>DB_SCRIPTS</artifactId>
<version>2.0.0.1</version>


<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/assembly/descriptor.xml</descriptor>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<distributionManagement>
<snapshotRepository>
<id>wvoNexus</id>
<file>${project.artifactId}-${project.version}.zip</file>
<url>http://nexus.corproot.com/nexus/content/repositories/snapshots/</url>
</snapshotRepository>

<repository>
<id>wvoNexus</id>
<file>${project.artifactId}-${project.version}.zip</file>
<url>http://nexus.corproot.com/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>

</project>

程序集插件描述 rune 件:
<assembly>
<formats>
<format>zip</format>
</formats>

<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>DB_Files</outputDirectory>
</fileSet>
</fileSets>
</assembly>

执行的命令:
mvn -X clean package deploy:deploy-file

错误:
[ERROR] Malformed POM C:\Divakar\MavenPrototype\DB_Maven_Test\dev\pom.xml: Unrecognised tag: 'file' (position: START_TAG seen ...<id>wvoNexus</id>\r\n\t\t\t<file>... @37:10)  @ C:\Divakar\MavenPrototype\DB_Maven_Test\dev\pom.xml, line 37, column 10

最佳答案

首先,您必须像这样修复 distributionManagement 区域中的错误:

  <distributionManagement>
<snapshotRepository>
<id>wvoNexus</id>
<url>http://nexus.corproot.com/nexus/content/repositories/snapshots/</url>
</snapshotRepository>

<repository>
<id>wvoNexus</id>
<url>http://nexus.corproot.com/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>

如果您解决了这个问题,您可以通过以下方式简单地将文件部署到您的 nexus:
mvn clean deploy

如果您不喜欢部署 jar,则需要像这样更改 pom 中的打包类型:

<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>com.wyndhamvo.prototype.dbscripts</groupId>
<artifactId>DB_SCRIPTS</artifactId>
<version>2.0.0.1</version>
<packaging>pom</packaging>


<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/assembly/descriptor.xml</descriptor>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

此外,我建议像这样定义您使用的插件的版本:

    <build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptor>src/assembly/descriptor.xml</descriptor>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

关于maven - 如何在 Maven 中仅部署 zip Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25441633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com