gpt4 book ai didi

plugins - Maven 程序集 - 读取程序集时出错

转载 作者:行者123 更新时间:2023-12-03 11:40:52 31 4
gpt4 key购买 nike

我已经定义了一个个性化的 jar-with-dependencies 程序集描述符。但是,当我使用 mvn assembly:assembly 执行它时,我得到:

...
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] javax/ already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] [assembly:assembly {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error reading assemblies: No assembly descriptors found.

我的 jar-with-dependencies.xml src/main/资源/程序集/ .

我的程序集描述符如下:
<?xml version='1.0' encoding='UTF-8'?>
<assembly>
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>

<dependencySets>
<dependencySet>
<scope>runtime</scope>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/LICENSE*</exclude>
<exclude>**/README*</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>

<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/META-INF/services</directory>
<outputDirectory>META-INF/services</outputDirectory>
</fileSet>
</fileSets>

</assembly>

我的项目 pom.xml 是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>jar-with-dependencies.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>org.my.app.HowTo</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>

执行 mvn assembly:assembly 时,解包依赖项,解包完成后出现上一个错误。

此外,如果我执行 mvn -e assembly:assembly 表示没有找到描述符,但是它会尝试解压缩依赖项并创建一个具有依赖项的 JAR,但它不包含 META-INF/services/* 中指定的描述符:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error reading assemblies: No assembly descriptors found.

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error reading assemblies: No assembly descriptors found.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error reading assemblies: No assembly descriptors found.
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:356)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.plugin.assembly.io.AssemblyReadException: No assembly descriptors found.
at org.apache.maven.plugin.assembly.io.DefaultAssemblyReader.readAssemblies(DefaultAssemblyReader.java:206)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:352)
... 19 more

我没有看到我的错误。有人有解决方案吗?

最佳答案

这里有两个问题。首先,使用自己的描述符时,必须指定 的路径您自定义的描述 rune 件(顺便说一下,您可以使用任何位置,但将描述符放在 src/main/resources 中可能不是最佳选择,您真的不希望将描述符打包在您的应用程序中,我会使用标准位置是 src/main/assembly,如 this page 中所述)。

<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>

二、您的 configuration元素当前位于 execution 中 block ,因此特定于 这个执行。换句话说,如果您运行 assembly:assembly,它将不适用。在命令行上。所以,如果你想调用 assembly:assembly使用自定义描述符,请使用:
mvn assembly:assembly -Ddescriptor=path/to/descriptor.xml

或移动 configurationexecution元素(使配置全局化):
<project>
...
<build>
...
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>path/to/descriptor.xml</descriptor>
</descriptors>
...
</configuration>
</plugin>
</plugins>
...
</build>
...
</project>

关于plugins - Maven 程序集 - 读取程序集时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2463721/

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