gpt4 book ai didi

java - Maven 依赖插件试图加载不存在的类 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact'

转载 作者:行者123 更新时间:2023-11-30 11:18:33 25 4
gpt4 key购买 nike

对于我正在尝试构建的所有项目,我从 maven 依赖插件中收到一个奇怪的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:copy (get-native-libs) on project tradestp-parent: Unable to parse configuration of mojo org.apache.maven.plugins:ma ven-dependency-plugin:2.8:copy: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact' -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:copy (get-native-libs) on project tradestp-parent: Unable to parse c onfiguration of mojo org.apache.maven.plugins:maven-dependency-plugin:2.8:copy: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
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.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.apache.maven.plugins:maven-dependency-plugin:2.8:copy: Error loading class 'org.apache.maven. plugin.dependency.fromConfiguration.Artifact'
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:564)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:496)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:96)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 19 more
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact'
at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration(CollectionConverter.java:174)
at org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:218)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:137)
at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:534)
... 22 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.plugin.dependency.fromConfiguration.Artifact
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration(CollectionConverter.java:161)
... 26 more

奇怪的是,它正在寻找的类 org.apache.maven.plugin.dependency.fromConfiguration.Artifact 真的不存在而且从来没有。

有没有人见过这个问题?为什么 maven 依赖插件试图加载一个不存在的类?

最佳答案

不确定您是否仍然遇到这个问题,但我刚刚遇到了同样的问题。

在我们的例子中,我们使用了 copy复制依赖项的目标。 pom 如下:

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-custom-artifact</id>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifact>
<groupId>some.artifact.groupid</groupId>
<artifactId>some.artifact.artifactid</artifactId>
</artifact>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

我找到了以下 answer到另一个问题,其中陈述如下:

The unpack and copy goals have to replicate some of the core resolution code. Unfortunately that resolution code was not really in a useable form api-wise. Because of this, those goals do not handle version ranges, and also don't resolve artifacts directly from the reactor (I frankly just never implemented them because it broke too many of the existing use cases, yeah core the resolution code was that bad)

A much better approach is to use the xxx-dependencies forms of these goals.

基于此,我将我们的 pom 更改为使用 copy-depenencies目标,如下:

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-custom-artifact</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>some.artifact.artifactid</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>

这样修改后,构建成功。希望这会有所帮助。

关于java - Maven 依赖插件试图加载不存在的类 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23810502/

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