Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven包含zip依赖项_Maven - Fatal编程技术网

Maven包含zip依赖项

Maven包含zip依赖项,maven,Maven,我们在本地存储库中托管了一个zip工件。在我的Maven项目中,我想检索这个zip依赖项。 在命令行中,我可以通过以下方式执行此操作: mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \ -DrepoUrl=https://artifactory.company.net/artifactory/releases\ -Dartifact=com.company.api:my-swagger-doc:$

我们在本地存储库中托管了一个zip工件。在我的Maven项目中,我想检索这个zip依赖项。 在命令行中,我可以通过以下方式执行此操作:

mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \
     -DrepoUrl=https://artifactory.company.net/artifactory/releases\
     -Dartifact=com.company.api:my-swagger-doc:$VERSION:zip:resources
这将下载
my-swagger-doc-2.5.3-resources.zip
。在我的pom.XML中,我不知道如何在XML中这样做

我的目标是从这个swagger文件生成Spring控制器

我的问题是: 如何下载这个zip工件并将其解压缩到我的目标目录中?

您可以使用Maven Dependency插件的目标

下面是一个示例代码段:

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
    <execution>
        <id>unpack</id>
        <phase>generate-resources</phase>
        <goals>
            <goal>unpack</goal>
        </goals>
        <configuration>
            <artifactItems>
                <artifactItem>
                    <groupId>groupId</groupId>
                    <artifactId>artifactId</artifactId>
                    <version>version</version>
                    <type>zip</type>
                    <outputDirectory>target/</outputDirectory>
                    <overWrite>true</overWrite>
                </artifactItem>
            </artifactItems>
        </configuration>
    </execution>
</executions>
org.apache.maven.plugins
maven依赖插件
3.1.1
打开
产生资源
打开
groupId
人工的
版本
拉链
目标/
符合事实的


在我的示例中,我将执行附加到
generateresources
阶段。根据您的构建,您可能必须将此目标的执行附加到适当的阶段

这起作用了。另外,为了获得my-swagger-doc-2.5.3-resources.zip,我必须向artifactItem添加“resources”