gpt4 book ai didi

maven - 如何解决 Maven 中的未知 Artifact 类型 [test-jar] 错误?

转载 作者:行者123 更新时间:2023-12-01 16:14:57 27 4
gpt4 key购买 nike

我在尝试使用 Maven 构建耳朵时遇到此错误。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml) on project cargooceanear: Failed to initialize ear modules: Unknown artifact type[test-jar] -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml) on project cargooceanear: Failed to initialize ear modules        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)        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:289)        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to initialize ear modules        at org.apache.maven.plugin.ear.AbstractEarMojo.execute(AbstractEarMojo.java:240)        at org.apache.maven.plugin.ear.GenerateApplicationXmlMojo.execute(GenerateApplicationXmlMojo.java:85)        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)        ... 19 moreCaused by: org.apache.maven.plugin.ear.UnknownArtifactTypeException: Unknown artifact type[test-jar]        at org.apache.maven.plugin.ear.util.ArtifactTypeMappingService.getStandardType(ArtifactTypeMappingService.java:151)        at org.apache.maven.plugin.ear.EarModuleFactory.newEarModule(EarModuleFactory.java:74)        at org.apache.maven.plugin.ear.AbstractEarMojo.execute(AbstractEarMojo.java:230)        ... 22 more

最佳答案

问题:maven-ear-plugin 给出错误: [INFO] 无法初始化 Ear 模块嵌入错误:未知 Artifact 类型 [zip]

原因:传递依赖项中的 zip 或不受支持的文件

解决方案:在windows下,打开cmd,先cd你的项目根目录,然后在cmd中输入mvn dependency:tree,找到有传递依赖的与 marven-ear-plugin 冲突。

例如未知 zip +- com.sun.xml.ws:samples:zip:2.2.10:编译意思是

<groupId>com.sun.xml.ws</groupId>
<artifactId>samples</artifactId>

例如更改 Ear pom:将排除项放入您的依赖项中

<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
...
<exclusions>
<exclusion>
<groupId>com.sun.xml.ws</groupId>
<artifactId>samples</artifactId>
</exclusion>
...
</exclusions>
</dependency>

与 +- com.sun.xml.ws:release-documentation:zip 相同

关于maven - 如何解决 Maven 中的未知 Artifact 类型 [test-jar] 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25263271/

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