我使用下面的描述符和 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> 


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!