您好我试图运行mvn clean install
,并且我收到的包裹不存在错误:
[DEBUG] Source roots:
[DEBUG] /Users/username/Projects/Venice/clarity/clarity-test-e2e/src/test/java
[DEBUG] Command line options:
[DEBUG] -d /Users/username/Projects/Venice/clarity/clarity-test-e2e/target/test-classes -classpath /Users/username/Projects/Venice/clarity/clarity-test-e2e/target/test-classes:/Users/username/Projects/Venice/clarity/clarity-test-e2e/target/classes:/Users/username/.m2/repository/uk/co/jemos/podam/podam/7.0.5.RELEASE/podam-7.0.5.RELEASE.jar:/Users/username/.m2/repository/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar:/Users/username/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar:/Users/username/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/Users/username/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/username/.m2/repository/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar:/Users/username/.m2/repository/org/testng/testng/6.11/testng-6.11.jar:/Users/username/.m2/repository/com/beust/jcommander/1.64/jcommander-1.64.jar:/Users/username/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/Users/username/Projects/Venice/clarity/clarity-etl/target/clarity-etl-1.0.0-SNAPSHOT.jar:/Users/username/Projects/Venice/clarity/clarity-statusserv/dao/target/clarity-statusserv-dao-1.0.0-SNAPSHOT.jar:/Users/username/Projects/Venice/clarity/clarity-statusserv/model/target/clarity-statusserv-model-1.0.0-SNAPSHOT.jar:/Users/username/.m2/repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar:/Users/username/.m2/repository/org/hibernate/hibernate-validator/5.4.1.Final/hibernate-validator-5.4.1.Final.jar:/Users/username/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/Users/username/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/Users/username/.m2/repository/org/projectlombok/lombok/1.16.12/lombok-1.16.12.jar:/Users/username/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.1.RELEASE/spring-boot-starter-1.5.1.RELEASE.jar:/Users/username/.m2/repository/org/springframework/boot/spring-boot/1.5.1.RELEASE/spring-boot-1.5.1.RELEASE.jar:/Users/username/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.1.RELEASE/spring-boot-autoconfigure-1.5.1.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-core/4.3.6.RELEASE/spring-core-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/apache/httpcomponents/httpclient/4.5.3/httpclient-4.5.3.jar:/Users/username/.m2/repository/org/apache/httpcomponents/httpcore/4.4.6/httpcore-4.4.6.jar:/Users/username/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/username/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/username/.m2/repository/org/springframework/boot/spring-boot-starter-log4j2/1.5.1.RELEASE/spring-boot-starter-log4j2-1.5.1.RELEASE.jar:/Users/username/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.7/log4j-slf4j-impl-2.7.jar:/Users/username/.m2/repository/org/apache/logging/log4j/log4j-api/2.7/log4j-api-2.7.jar:/Users/username/.m2/repository/org/apache/logging/log4j/log4j-core/2.7/log4j-core-2.7.jar:/Users/username/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.22/jcl-over-slf4j-1.7.22.jar:/Users/username/.m2/repository/org/slf4j/jul-to-slf4j/1.7.22/jul-to-slf4j-1.7.22.jar:/Users/username/.m2/repository/org/springframework/data/spring-data-couchbase/2.2.0.RELEASE/spring-data-couchbase-2.2.0.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-context/4.3.6.RELEASE/spring-context-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-aop/4.3.6.RELEASE/spring-aop-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-beans/4.3.6.RELEASE/spring-beans-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-expression/4.3.6.RELEASE/spring-expression-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-web/4.3.6.RELEASE/spring-web-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/springframework/spring-tx/4.3.6.RELEASE/spring-tx-4.3.6.RELEASE.jar:/Users/username/.m2/repository/org/springframework/data/spring-data-commons/1.13.0.RELEASE/spring-data-commons-1.13.0.RELEASE.jar:/Users/username/.m2/repository/com/couchbase/client/java-client/2.3.7/java-client-2.3.7.jar:/Users/username/.m2/repository/com/couchbase/client/core-io/1.3.7/core-io-1.3.7.jar:/Users/username/.m2/repository/io/reactivex/rxjava/1.1.8/rxjava-1.1.8.jar:/Users/username/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.6/jackson-databind-2.8.6.jar:/Users/username/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/Users/username/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.6/jackson-core-2.8.6.jar:/Users/username/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.1.RELEASE/spring-boot-starter-web-1.5.1.RELEASE.jar:/Users/username/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.1.RELEASE/spring-boot-starter-tomcat-1.5.1.RELEASE.jar:/Users/username/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar:/Users/username/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.11/tomcat-embed-el-8.5.11.jar:/Users/username/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.11/tomcat-embed-websocket-8.5.11.jar:/Users/username/.m2/repository/org/springframework/spring-webmvc/4.3.6.RELEASE/spring-webmvc-4.3.6.RELEASE.jar: -sourcepath /Users/username/Projects/Venice/clarity/clarity-test-e2e/src/test/java: -s /Users/username/Projects/Venice/clarity/clarity-test-e2e/target/generated-test-sources/test-annotations -g -nowarn -target 1.8 -source 1.8 -encoding UTF-8
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[INFO] Compiling 3 source files to /Users/username/Projects/Venice/clarity/clarity-test-e2e/target/test-classes
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/username/Projects/Venice/clarity/clarity-test-e2e/src/test/java/com/company/consumer/tools/clarity/e2e/etl/ETLHappyPathSuite.java:[6,58] package com.company.consumer.tools.clarity.etl.dao.v1.state does not exist
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Clarity - Parent Pom ............................... SUCCESS [ 0.256 s]
[INFO] Clarity - Status Service Parent Pom ................ SUCCESS [ 0.007 s]
[INFO] Clarity - Status Service Model ..................... SUCCESS [ 2.416 s]
[INFO] Clarity - Status Service DAO Components ............ SUCCESS [ 0.693 s]
[INFO] Clarity - Status Service ........................... SUCCESS [ 2.119 s]
[INFO] Clarity - Checkstyle Configuration ................. SUCCESS [ 0.034 s]
[INFO] Clarity - ETL ...................................... SUCCESS [ 0.776 s]
[INFO] Clarity - Testing E2E .............................. FAILURE [ 0.216 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.039 s
[INFO] Finished at: 2017-06-05T11:47:36-07:00
[INFO] Final Memory: 47M/536M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project clarity-test-e2e: Compilation failure
[ERROR] /Users/username/Projects/Venice/clarity/clarity-test-e2e/src/test/java/com/company/consumer/tools/clarity/e2e/etl/ETLHappyPathSuite.java:[6,58] package com.company.consumer.tools.clarity.etl.dao.v1.state does not exist
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project clarity-test-e2e: Compilation failure
/Users/username/Projects/Venice/clarity/clarity-test-e2e/src/test/java/com/company/consumer/tools/clarity/e2e/etl/ETLHappyPathSuite.java:[6,58] package com.company.consumer.tools.clarity.etl.dao.v1.state does not exist
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
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:498)
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.compiler.CompilationFailureException: Compilation failure
/Users/username/Projects/Venice/clarity/clarity-test-e2e/src/test/java/com/company/consumer/tools/clarity/e2e/etl/ETLHappyPathSuite.java:[6,58] package com.company.consumer.tools.clarity.etl.dao.v1.state does not exist
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:152)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :clarity-test-e2e
依赖pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ================================================================== -->
<!-- Parent -->
<!-- ================================================================== -->
<parent>
<groupId>com.company.consumer.tools.clarity</groupId>
<artifactId>clarity-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<!-- ================================================================== -->
<!-- Application Description -->
<!-- ================================================================== -->
<artifactId>clarity-etl</artifactId>
<packaging>jar</packaging>
<name>Clarity - ETL</name>
<description>
</description>
<properties>
<app.mainClass>com.company.consumer.tools.clarity.etl.ETLMain</app.mainClass>
<docker.image.prefix>dockerhub.companycorp.com/username</docker.image.prefix>
</properties>
<!-- ================================================================== -->
<!-- Dependencies -->
<!-- ================================================================== -->
<dependencies>
<!-- ================================================================== -->
<!-- Clarity Dependencies -->
<dependency>
<groupId>com.company.consumer.tools.clarity</groupId>
<artifactId>clarity-statusserv-dao</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- ================================================================== -->
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- ================================================================== -->
<!-- Build -->
<!-- ================================================================== -->
<build>
<plugins>
<!-- ================================================================== -->
<!-- Invoke spring boot application. -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${app.mainClass}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<useConfigFile>true</useConfigFile>
<registryUrl>https://dockerhub.companycorp.com/</registryUrl>
</configuration>
</plugin>
</plugins>
</build>
</project>
现在
[username]@[localhost] (master)$jar -tf
/Users/username/.m2/repository/com/company/consumer/tools/clarity/clarity-
etl/1.0.0-SNAPSHOT/clarity-etl-1.0.0-SNAPSHOT.jar | grep dao
BOOT-INF/classes/com/company/consumer/tools/clarity/etl/dao/
BOOT-INF/classes/com/company/consumer/tools/clarity/etl/dao/v1/
BOOT-INF/classes/com/company/consumer/tools/clarity/etl/dao/v1/state/
BOOT-INF/classes/com/company/consumer/tools/clarity/etl/dao/v1/
state/EtlStateDocument.class
BOOT-INF/classes/com/company/consumer/tools/clarity/etl/dao/v1/
state/EtlStateRepository.class
运行mvn dependency:build-classpath
后,我可以看到clarity-etl-1.0.0-SNAPSHOT.jar
(依赖项)在类路径上。
这是依赖的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ================================================================== -->
<!-- Parent -->
<!-- ================================================================== -->
<parent>
<groupId>com.company.consumer.tools.clarity</groupId>
<artifactId>clarity-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<!-- ================================================================== -->
<!-- Project Settings -->
<!-- ================================================================== -->
<artifactId>clarity-test-e2e</artifactId>
<name>Clarity - Testing E2E</name>
<description>
The end to end testing for Clarity.
</description>
<properties>
<org.apache.maven.surefire.version>2.19.1</org.apache.maven.surefire.version>
</properties>
<!-- ================================================================== -->
<!-- Distribution Management -->
<!-- ================================================================== -->
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Nexus Releases</name>
<url>http://nexus.company.com/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Nexus Snapshots</name>
<url>http://nexus.company.com/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<!-- ================================================================== -->
<!-- Repositories -->
<!-- ================================================================== -->
<repositories>
<repository>
<id>company-nexus</id>
<name>company Nexus</name>
<layout>default</layout>
<url>http://nexus.company.com/nexus/content/groups/public-all/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>uk.co.jemos.podam</groupId>
<artifactId>podam</artifactId>
<version>7.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>com.company.consumer.tools.clarity</groupId>
<artifactId>clarity-etl</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- ================================================================== -->
<!-- Build -->
<!-- ================================================================== -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>e2e</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${org.apache.maven.surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${org.apache.maven.surefire.version}</version>
</dependency>
</dependencies>
<configuration>
<systemPropertyVariables>
<dbhost>${dbhost}</dbhost>
<dbuser>${dbuser}</dbuser>
<dbpass>${dbpass}</dbpass>
<saasEndpoint>${saasEndpoint}</saasEndpoint>
<cssEndpoint>${cssEndpoint}</cssEndpoint>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<parallel>all</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
<properties>
<property>
<name>suitethreadpoolsize</name>
<value>20</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
我不确定为什么在命令行中使用mvn clean install
无法正确构建,但是当我从eclipse执行时它似乎工作正常。我认为默认情况下Eclipse提供了类路径上的所有类(无论范围如何),但是我尝试过不同的范围无济于事。
非常感谢任何帮助。提前谢谢!
答案 0 :(得分:1)
您不能将clarity-etl-1.0.0-SNAPSHOT.jar
用作常规jar依赖项。请注意,此jar中的类位于BOOT-INF/classes
下,它由Spring Boot使用,但被Java编译器忽略。
如果你的目标是测试Spring Boot应用程序(而不是使用jar作为依赖项),那么Spring Boot提供了简单的方法来实现它。 例如,请参阅https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html。
另一方面,如果将类包含在另一个应用程序中很重要,那么How to add a dependency to a Spring Boot Jar in another project?可能会对您在评论中指出的内容有所帮助。