我目前正在使用Maven的Java项目遇到麻烦。我的pom中有一个依赖关系,指向Apache的commons-cli
版本1.4,如:
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
现在在运行时我得到一个NoSuchMethodException
,因为显然,这个库的旧版本被加载到缺少某种方法的类路径中。
但是,我的项目中没有引用其他版本,mvn dependency:tree
(使用详细选项!)除了1.4版本之外没有列出commons-cli
的任何其他导入明确使用。
但是,当我清除.m2中的存储库并运行maven安装时,我发现commons-cli库的版本1.0和1.2都被拉了。如果它们不是我的任何导入的传递依赖,Maven会有什么其他原因来提取这些依赖关系?
编辑:这是完整有效的pom。
<!-- ====================================================================== -->
<!-- -->
<!-- Generated on 2018-05-23T06:35:53 -->
<!-- -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- -->
<!-- Effective POM for project 'com.crawljax:crawljax-cli:jar:3.7-SNAPSHOT' -->
<!-- -->
<!-- ====================================================================== -->
<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>
<groupId>com.crawljax</groupId>
<artifactId>crawljax-parent-pom</artifactId>
<version>3.7-SNAPSHOT</version>
</parent>
<groupId>com.crawljax</groupId>
<artifactId>crawljax-cli</artifactId>
<version>3.7-SNAPSHOT</version>
<name>Crawljax CLI</name>
<description>The Crawljax command line interface</description>
<url>http://crawljax.com/crawljax-cli</url>
<inceptionYear>2012</inceptionYear>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>amesbah</id>
<name>Ali Mesbah</name>
<email>a.mesbah@gmail.com</email>
<url>http://www.ece.ubc.ca/~amesbah/</url>
<organization>SALTLab, UBC</organization>
<organizationUrl>http://salt.ece.ubc.ca</organizationUrl>
<timezone>-8</timezone>
</developer>
<developer>
<id>arie.van.deursen</id>
<name>Arie van Deursen</name>
<email>arie.vanDeursen@tudelft.nl</email>
<url>http://www.st.ewi.tudelft.nl/~arie/</url>
<organization>SWERL, TU Delft</organization>
<organizationUrl>http://swerl.tudelft.nl</organizationUrl>
<timezone>+1</timezone>
</developer>
<developer>
<id>alexnederlof</id>
<name>Alex Nederlof</name>
<email>alex@nederlof.com</email>
<url>http://alex.nederlof.com</url>
<organization>TU Delft</organization>
<timezone>+1</timezone>
</developer>
</developers>
<mailingLists>
<mailingList>
<name>Crawljax Mailing List</name>
<subscribe>http://groups.google.com/group/crawljax/subscribe</subscribe>
<unsubscribe>crawljax+unsubscribe@googlegroups.com</unsubscribe>
<post>crawljax@googlegroups.com</post>
<archive>http://groups.google.com/group/crawljax</archive>
</mailingList>
</mailingLists>
<scm>
<connection>scm:git:git@github.com:crawljax/crawljax.git/crawljax-cli</connection>
<developerConnection>scm:git:git@github.com:crawljax/crawljax.git/crawljax-cli</developerConnection>
<url>https://github.com/crawljax/crawljax/crawljax-cli</url>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/crawljax/crawljax/issues</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>http://jenkins.crawljax.com</url>
</ciManagement>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<properties>
<arguments />
<jetty.version>9.3.0.M1</jetty.version>
<logback.version>1.1.2</logback.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<metrics.version>3.0.2</metrics.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<selenium.version>3.0.0</selenium.version>
<slf4j.version>1.7.7</slf4j.version>
<sonatypeOssDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/snapshots/</sonatypeOssDistMgmtSnapshotsUrl>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.crawljax</groupId>
<artifactId>crawljax-core</artifactId>
<version>3.7-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.crawljax.plugins</groupId>
<artifactId>crawloverview-plugin</artifactId>
<version>3.7-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/src/main/java</sourceDirectory>
<scriptSourceDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/src/test/java</testSourceDirectory>
<outputDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target/classes</outputDirectory>
<testOutputDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target/test-classes</testOutputDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/src/test/resources</directory>
</testResource>
</testResources>
<directory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target</directory>
<finalName>crawljax-cli-3.7-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
<useReleaseProfile>false</useReleaseProfile>
<arguments> -Psonatype-oss-release</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.1.10</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<dateFormat>yyyy-MM-dd HH:mm:ss z</dateFormat>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<gitDescribe>
<always>true</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
</gitDescribe>
</configuration>
</execution>
</executions>
<configuration>
<dateFormat>yyyy-MM-dd HH:mm:ss z</dateFormat>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<gitDescribe>
<always>true</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
</gitDescribe>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version>
<message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>zip-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/resources/jar-with-dependencies.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
<configuration>
<descriptors>
<descriptor>src/main/resources/jar-with-dependencies.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
<configuration>
<goals>assembly:assembly</goals>
<tagNameFormat>crawljax-@{project.version}</tagNameFormat>
<mavenExecutorId>forked-path</mavenExecutorId>
<useReleaseProfile>false</useReleaseProfile>
<arguments> -Psonatype-oss-release</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.crawljax.cli.JarRunner</mainClass>
</manifest>
</archive>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.crawljax.cli.JarRunner</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.crawljax.cli.JarRunner</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<file>crawljax-cli-3.7-SNAPSHOT.zip</file>
<packaging>zip</packaging>
</configuration>
</execution>
</executions>
<configuration>
<file>crawljax-cli-3.7-SNAPSHOT.zip</file>
<packaging>zip</packaging>
</configuration>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.1.10</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<dateFormat>yyyy-MM-dd HH:mm:ss z</dateFormat>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<gitDescribe>
<always>true</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
</gitDescribe>
</configuration>
</execution>
</executions>
<configuration>
<dateFormat>yyyy-MM-dd HH:mm:ss z</dateFormat>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<gitDescribe>
<always>true</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
</gitDescribe>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>/home/roper/idp-business-logic/crawljax-mainline/crawljax/cli/target/site</outputDirectory>
</reporting>
</project>