如图所示,新建了一个简单的工程,结构为:
wrap
-main 依赖mod工程
-mod
配置没问题,但在main工程里配置了jetty插件运行就会 报错,找不到mod这个依赖的jar
[ERROR] Failed to execute goal on project main: Could not resolve dependencies for project com.kongwu:main:war:1.0: Failure to find com.kongwu:mod🏺1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
其实没父目录的maven工程是有问题的。这边公司是这样的。
正确的做法是
root
|-web
|-service
|-dao
这些模块中都有pom。然后root中配置好pom后。在各个子系统中加点依赖就行了。
你可以新建project,选maven,然后一路下去。
建设好的工程中,在添加module,选择父节点为root,然后添加好子工程。
最后一个编译就OK了
[INFO]Scanningforprojects...
[INFO]------------------------------------------------------------------------
[INFO]ReactorBuildOrder:
[INFO]
[INFO]TestMaven
[INFO]dao
[INFO]service
[INFO]
[INFO]------------------------------------------------------------------------
[INFO]BuildingTestMaven1.0-SNAPSHOT
[INFO]------------------------------------------------------------------------
[INFO]
[INFO]---maven-clean-plugin:2.5:clean(default-clean)@TestMaven---
[INFO]
[INFO]---maven-install-plugin:2.4:install(default-install)@TestMaven---
[INFO]InstallingD:\workspace\testMaven\pom.xmltoD:\mvn_repo\TestMaven\TestMaven\1.0-SNAPSHOT\TestMaven-1.0-SNAPSHOT.pom
[INFO]
[INFO]------------------------------------------------------------------------
[INFO]Buildingdao1.0-SNAPSHOT
[INFO]------------------------------------------------------------------------
[INFO]
[INFO]---maven-clean-plugin:2.5:clean(default-clean)@dao---
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\dao\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@dao---
[INFO]Noteststorun.
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@dao---
[INFO]Buildingjar:D:\workspace\testMaven\dao\target\dao-1.0-SNAPSHOT.jar
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\dao\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@dao---
[INFO]Noteststorun.
[INFO]Skippingexecutionofsurefirebecauseithasalreadybeenrunforthisconfiguration
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@dao---
[INFO]
[INFO]---maven-install-plugin:2.4:install(default-install)@dao---
[INFO]InstallingD:\workspace\testMaven\dao\target\dao-1.0-SNAPSHOT.jartoD:\mvn_repo\TestMaven\dao\1.0-SNAPSHOT\dao-1.0-SNAPSHOT.jar
[INFO]InstallingD:\workspace\testMaven\dao\pom.xmltoD:\mvn_repo\TestMaven\dao\1.0-SNAPSHOT\dao-1.0-SNAPSHOT.pom
[INFO]
[INFO]------------------------------------------------------------------------
[INFO]Buildingservice1.0-SNAPSHOT
[INFO]------------------------------------------------------------------------
[INFO]
[INFO]---maven-clean-plugin:2.5:clean(default-clean)@service---
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\service\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@service---
[INFO]Noteststorun.
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@service---
[INFO]Buildingjar:D:\workspace\testMaven\service\target\service-1.0-SNAPSHOT.jar
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\service\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@service---
[INFO]Noteststorun.
[INFO]Skippingexecutionofsurefirebecauseithasalreadybeenrunforthisconfiguration
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@service---
[INFO]
[INFO]---maven-install-plugin:2.4:install(default-install)@service---
[INFO]InstallingD:\workspace\testMaven\service\target\service-1.0-SNAPSHOT.jartoD:\mvn_repo\TestMaven\service\1.0-SNAPSHOT\service-1.0-SNAPSHOT.jar
[INFO]InstallingD:\workspace\testMaven\service\pom.xmltoD:\mvn_repo\TestMaven\service\1.0-SNAPSHOT\service-1.0-SNAPSHOT.pom
[INFO]------------------------------------------------------------------------
[INFO]ReactorSummary:
[INFO]
[INFO]TestMaven..........................................SUCCESS[ 0.709s]
[INFO]dao................................................SUCCESS[ 0.949s]
[INFO]service............................................SUCCESS[ 0.088s]
[INFO]------------------------------------------------------------------------
[INFO]BUILDSUCCESS
[INFO]------------------------------------------------------------------------
[INFO]Totaltime:1.848s
[INFO]Finishedat:2016-09-27T17:35:34+08:00
[INFO]FinalMemory:11M/150M
[INFO]------------------------------------------------------------------------
Processfinishedwithexitcode0
添加项目依赖。(这个只是保证编译时不报错)
另外还要在子POMMOD中,加入一句这个
< parent > < groupId >父GROUPID </ groupId > < artifactId >父ARTIFACTID </ artifactId > < version >父版本 </ version > < relativePath >../mod/pom.xml </ relativePath > </ parent >把mod移动和wap同级,然后修改mod中的pom代码如上。
工程如下这样:
其实没父目录的maven工程是有问题的。这边公司是这样的。
正确的做法是
root
|-web
|-service
|-dao
这些模块中都有pom。然后root中配置好pom后。在各个子系统中加点依赖就行了。
你可以新建project,选maven,然后一路下去。
建设好的工程中,在添加module,选择父节点为root,然后添加好子工程。
最后一个编译就OK了
[INFO]Scanningforprojects...
[INFO]------------------------------------------------------------------------
[INFO]ReactorBuildOrder:
[INFO]
[INFO]TestMaven
[INFO]dao
[INFO]service
[INFO]
[INFO]------------------------------------------------------------------------
[INFO]BuildingTestMaven1.0-SNAPSHOT
[INFO]------------------------------------------------------------------------
[INFO]
[INFO]---maven-clean-plugin:2.5:clean(default-clean)@TestMaven---
[INFO]
[INFO]---maven-install-plugin:2.4:install(default-install)@TestMaven---
[INFO]InstallingD:\workspace\testMaven\pom.xmltoD:\mvn_repo\TestMaven\TestMaven\1.0-SNAPSHOT\TestMaven-1.0-SNAPSHOT.pom
[INFO]
[INFO]------------------------------------------------------------------------
[INFO]Buildingdao1.0-SNAPSHOT
[INFO]------------------------------------------------------------------------
[INFO]
[INFO]---maven-clean-plugin:2.5:clean(default-clean)@dao---
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\dao\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@dao---
[INFO]Noteststorun.
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@dao---
[INFO]Buildingjar:D:\workspace\testMaven\dao\target\dao-1.0-SNAPSHOT.jar
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@dao---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\dao\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@dao---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@dao---
[INFO]Noteststorun.
[INFO]Skippingexecutionofsurefirebecauseithasalreadybeenrunforthisconfiguration
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@dao---
[INFO]
[INFO]---maven-install-plugin:2.4:install(default-install)@dao---
[INFO]InstallingD:\workspace\testMaven\dao\target\dao-1.0-SNAPSHOT.jartoD:\mvn_repo\TestMaven\dao\1.0-SNAPSHOT\dao-1.0-SNAPSHOT.jar
[INFO]InstallingD:\workspace\testMaven\dao\pom.xmltoD:\mvn_repo\TestMaven\dao\1.0-SNAPSHOT\dao-1.0-SNAPSHOT.pom
[INFO]
[INFO]------------------------------------------------------------------------
[INFO]Buildingservice1.0-SNAPSHOT
[INFO]------------------------------------------------------------------------
[INFO]
[INFO]---maven-clean-plugin:2.5:clean(default-clean)@service---
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\service\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@service---
[INFO]Noteststorun.
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@service---
[INFO]Buildingjar:D:\workspace\testMaven\service\target\service-1.0-SNAPSHOT.jar
[INFO]
[INFO]---maven-resources-plugin:2.6:resources(default-resources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]Copying0resource
[INFO]
[INFO]---maven-compiler-plugin:3.1:compile(default-compile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@service---
[WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
[INFO]skipnonexistingresourceDirectoryD:\workspace\testMaven\service\src\test\resources
[INFO]
[INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@service---
[INFO]Nothingtocompile-allclassesareuptodate
[INFO]
[INFO]---maven-surefire-plugin:2.12.4:test(default-test)@service---
[INFO]Noteststorun.
[INFO]Skippingexecutionofsurefirebecauseithasalreadybeenrunforthisconfiguration
[INFO]
[INFO]---maven-jar-plugin:2.4:jar(default-jar)@service---
[INFO]
[INFO]---maven-install-plugin:2.4:install(default-install)@service---
[INFO]InstallingD:\workspace\testMaven\service\target\service-1.0-SNAPSHOT.jartoD:\mvn_repo\TestMaven\service\1.0-SNAPSHOT\service-1.0-SNAPSHOT.jar
[INFO]InstallingD:\workspace\testMaven\service\pom.xmltoD:\mvn_repo\TestMaven\service\1.0-SNAPSHOT\service-1.0-SNAPSHOT.pom
[INFO]------------------------------------------------------------------------
[INFO]ReactorSummary:
[INFO]
[INFO]TestMaven..........................................SUCCESS[ 0.709s]
[INFO]dao................................................SUCCESS[ 0.949s]
[INFO]service............................................SUCCESS[ 0.088s]
[INFO]------------------------------------------------------------------------
[INFO]BUILDSUCCESS
[INFO]------------------------------------------------------------------------
[INFO]Totaltime:1.848s
[INFO]Finishedat:2016-09-27T17:35:34+08:00
[INFO]FinalMemory:11M/150M
[INFO]------------------------------------------------------------------------
Processfinishedwithexitcode0
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。