Maven包装器与本地安装的maven

时间:2018-05-03 12:46:01

标签: java maven

我正在使用Maven包装器运行Spring Boot项目。

从控制台,我可以运行mvn clean install。从Eclipse开始,我可以通过右键单击运行它 - >以 - >运行Maven安装。

但是,从命令行使用Maven包装器时:

./mvnw clean install

它不起作用。我认为这是因为运行包装器时输出顶部有以下几行:

  

[警告] org.apache.camel的pOM:camel-spring-boot:jar:2.21.0无效,传递依赖(如果有)将不可用,启用调试日志以获取更多详细信息

     

[警告] org.apache.camel的POM:camel-core:jar:2.21.0无效,传递依赖(如果有)将无效,启用调试日志以获取更多详细信息

     

[警告] org.apache.camel的POM:camel-servlet:jar:2.21.0无效,传递依赖(如果有)将不可用,启用调试日志记录以获取更多详细信息

     

[警告] org.apache.camel的pOM:camel-sql:jar:2.21.0无效,传递依赖(如果有)将无效,启用调试日志以获取更多详细信息

     

[警告] org.apache.camel的POM:camel-test-spring:jar:2.21.0无效,传递依赖(如果有)将不可用,启用调试日志记录以获取更多详细信息

最后,整个构建失败了:

Caused by: java.lang.ClassNotFoundException: org.apache.camel.spring.SpringCamelContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.apache.camel.test.spring.CamelSpringBootExecutionListener.prepareTestInstance(CamelSpringBootExecutionListener.java:41)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

我可以通过指出要下载的目录来强制它运行以获得全新安装:

./mvnw clean install -Dmaven.repo.local=tmp

我对包装器的主要用途是在我们的CI环境中,因为我们之后丢弃了图像,它基本上会强制上述行。

我本地安装的maven具有以下版本信息(mvn -v):

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-121-generic", arch: "amd64", family: "unix"

包装器具有以下版本信息(mvn -v):

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
Maven home: /home/kajo/.m2/wrapper/dists/apache-maven-3.5.2-bin/7hf0mht29afbpa1e4v2d1a16p0/apache-maven-3.5.2
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-121-generic", arch: "amd64", family: "unix"

我很好奇它为什么不起作用以及问题的根源是什么。当我必须下载全新安装以使用包装器工作时,编译和测试构建需要更长的时间。

0 个答案:

没有答案