开发者社区> 问答> 正文

maven 多模块项目, 依赖问题?报错

项目xx-parent 下有多个模块 xx-a, xx-b 

xx-a 依赖 xx-b, 但是我在pom.xml添加了依赖还是没用

在xx-b 里执行了mvn clean install, 安装到了本地库还是没用

最后我在xx-parent 下执行mvn clean install, 还是没用

报错:

 Failed to execute goal on project woyin-admin: Could not resolve dependencies for project com.woyin:woyin-admin:war:1.0-SNAPSHOT: Failed to collect dependencies at com.woyin:woyin-comm🏺1.0-SNAPSHOT: Failed to read artifact descriptor for com.woyin:woyin-comm🏺1.0-SNAPSHOT: Could not find artifact com.woyin:Woyin-Parent:pom:1.0-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project woyin-admin: Could not resolve dependencies for project com.woyin:woyin-admin:war:1.0-SNAPSHOT: Failed to collect dependencies at com.woyin:woyin-comm🏺1.0-SNAPSHOT
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
        at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:245)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
        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:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        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.project.DependencyResolutionException: Could not resolve dependencies for project com.woyin:woyin-admin:war:1.0-SNAPSHOT: Failed to collect dependencies at com.woyin:woyin-comm🏺1.0-SNAPSHOT
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:180)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
        ... 23 more
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at com.woyin:woyin-comm🏺1.0-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:291)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:316)
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:172)
        ... 24 more
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for com.woyin:woyin-comm🏺1.0-SNAPSHOT
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:329)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:198)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:535)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:519)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351)
        at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
        ... 26 more
Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact com.woyin:Woyin-Parent:pom:1.0-SNAPSHOT
        at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:177)
        at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:226)
        at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1000)
        at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:800)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:329)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:320)
        ... 33 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.woyin:Woyin-Parent:pom:1.0-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
        at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:173)
        ... 38 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.woyin:Woyin-Parent:pom:1.0-SNAPSHOT
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:434)
        ... 41 more
<p>
	<br>
</p>
<p>
	<br>
</p>


展开
收起
爱吃鱼的程序员 2020-06-09 14:41:35 1308 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    你自己仔细检查试一下。


    未找到com.woyin:Woyin-Parent:pom:1.0-SNAPSHOT我在这个parent下,执行了mvncleaninstall,然后再到之前的模块下执行mvncleancompile还是没用

    这种多模块依赖的maven工程,如果存在pom文件依赖,请在根目录下执行mvn命令。要不会找不到依赖的pom文件。

    如果是在根目录下执行了,那还要继续找问题~~~



    回复 @陈鹏烨:好吧。多谢了回复 @plugin:是不需要了。如果我说的问题都ok,那你只能继续找了,祝好运回复 @陈鹏烨:woyin-comm是模块,pom.xml里已经定义了<parent>就是Woyin-Parent吧。应该不需要再添加依赖了吧回复 @plugin:我看报错的堆栈信息,显示的编译woyin-comm的时候找不到com.woyin:Woyin-Parent:pom:1.0-SNAPSHOT回复 @plugin:woyin-comm里面是否写了parent的依赖?

    执行以下compile命令

    写得不错,这里再补充一下,相互学习,共同进步。

    Eclipse下Maven工程多模块继承和聚合创建(详解)

    2020-06-09 14:41:51
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
使用Spring.Initializr定制工程脚手架 立即下载
陈曦:使用Spring.Initializr定制工程脚手架 立即下载
低代码开发师(初级)实战教程 立即下载

相关镜像