Maven构建引发异常 - com / google / common / base / Strings

时间:2017-05-31 08:26:13

标签: java maven

问题:我在尝试构建项目时抛出异常

例外:

[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
---------------------------------------------------
constituent[0]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/
constituent[1]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-core-3.3.9.jar
constituent[2]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-model-3.3.9.jar
constituent[3]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-settings-3.3.9.jar
constituent[4]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-settings-builder-3.3.9.jar
constituent[5]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-builder-support-3.3.9.jar
constituent[6]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-repository-metadata-3.3.9.jar
constituent[7]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-artifact-3.3.9.jar
constituent[8]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-plugin-api-3.3.9.jar
constituent[9]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-model-builder-3.3.9.jar
constituent[10]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-aether-provider-3.3.9.jar
constituent[11]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-api-1.0.2.v20150114.jar
constituent[12]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-util-1.0.2.v20150114.jar
constituent[13]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/guice-4.0-no_aop.jar
constituent[14]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/plexus-interpolation-1.21.jar
constituent[15]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/plexus-utils-3.0.22.jar
constituent[16]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/plexus-component-annotations-1.6.jar
constituent[17]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/plexus-sec-dispatcher-1.3.jar
constituent[18]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/commons-lang3-3.4.jar
constituent[19]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-embedder-3.3.9.jar
constituent[20]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/plexus-cipher-1.7.jar
constituent[21]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/commons-cli-1.2.jar
constituent[22]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/maven-compat-3.3.9.jar
constituent[23]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/wagon-provider-api-2.10.jar
constituent[24]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/org.eclipse.sisu.plexus-0.3.2.jar
constituent[25]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/cdi-api-1.0.jar
constituent[26]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/jsr250-api-1.0.jar
constituent[27]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/org.eclipse.sisu.inject-0.3.2.jar
constituent[28]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/guava-18.0.jar
constituent[29]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-impl-1.0.2.v20150114.jar
constituent[30]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-spi-1.0.2.v20150114.jar
constituent[31]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-connector-okhttp-0.16.0.jar
constituent[32]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/okhttp-2.5.0.jar
constituent[33]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/okio-1.6.0.jar
constituent[34]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-connector-basic-1.0.2.v20150114.jar
constituent[35]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/aether-transport-wagon-1.0.2.v20150114.jar
constituent[36]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/wagon-file-2.10.jar
constituent[37]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime_1.7.0.20160603-1931/jars/commons-lang-2.6.jar
constituent[38]: file:/C:/java-neon/eclipse/configuration/org.eclipse.osgi/466/0/.cp/
constituent[39]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.7.0.20160603-1931/
constituent[40]: file:/C:/Users/<user>/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.7.0.20160603-1931/jars/slf4j-simple-1.7.5.jar
constituent[41]: file:/C:/java-neon/eclipse/configuration/org.eclipse.osgi/19/0/.cp/
---------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Strings
    at org.sonatype.nexus.maven.staging.deploy.DeployLifecycleParticipant.getPluginByGAFromContainer(DeployLifecycleParticipant.java:239)
    at org.sonatype.nexus.maven.staging.deploy.DeployLifecycleParticipant.getNexusMavenPluginFromContainer(DeployLifecycleParticipant.java:183)
    at org.sonatype.nexus.maven.staging.deploy.DeployLifecycleParticipant.getBuildPluginsNexusMavenPlugin(DeployLifecycleParticipant.java:164)
    at org.sonatype.nexus.maven.staging.deploy.DeployLifecycleParticipant.afterProjectsRead(DeployLifecycleParticipant.java:96)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:266)
    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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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: java.lang.ClassNotFoundException: com.google.common.base.Strings
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    ... 18 more

已尝试解决方案:

  1. 删除所有.m2和.p2目录并再次安装Eclipse。
  2. 包括番石榴maven依赖
  3. 已执行mvn dependency:tree。仍然得到上述例外。
  4. 上述解决方案均不适合我。

    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>
        <groupId>com.github</groupId>
        <artifactId>webdriverextensions</artifactId>
        <version>3.5.1</version>
        <name>Extended version of Selenium 3.4.0</name> 
        <properties>
            <!-- File Encoding -->
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    
            <!-- Dependency Versions -->
            <commons-lang3.version>3.5</commons-lang3.version>
            <codemodel.version>2.6</codemodel.version>
            <gson.version>2.8.0</gson.version>
            <junit.version>4.12</junit.version>
            <lambdaj.version>2.3.3</lambdaj.version>
            <logback.version>1.2.3</logback.version>
            <selenium.version>3.4.0</selenium.version>
            <htmlunit-driver.version>2.26</htmlunit-driver.version>
            <phantomjsdriver.version>1.4.2</phantomjsdriver.version>
    
            <!-- Plugin Versions -->
            <maven-deploy-plugin.version>2.8.1</maven-deploy-plugin.version>
            <maven-release-plugin.version>2.5</maven-release-plugin.version>
            <nexus-staging-maven-plugin.version>1.6.2</nexus-staging-maven-plugin.version>
            <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
            <maven-processor-plugin.version>2.2.4</maven-processor-plugin.version>
            <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
            <webdriverextensions-maven-plugin.version>3.1.1</webdriverextensions-maven-plugin.version>
            <maven-source-plugin.version>2.2.1</maven-source-plugin.version>
            <maven-javadoc-plugin.version>2.9.1</maven-javadoc-plugin.version>
            <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        </properties>
    
        <dependencies>
            <!-- custom jars -->
            <!-- https://mvnrepository.com/artifact/org.databene/databene-benerator -->
            <dependency>
                <groupId>org.databene</groupId>
                <artifactId>databene-benerator</artifactId>
                <version>0.9.8</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>2.3.23</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
            <dependency>
                <groupId>org.apache.tika</groupId>
                <artifactId>tika-core</artifactId>
                <version>1.14</version>
            </dependency>
            <dependency>
                <groupId>com.tngtech.java</groupId>
                <artifactId>junit-dataprovider</artifactId>
                <version>1.10.0</version>
                <scope>test</scope>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>3.14</version>
            </dependency>
            <dependency>
                <groupId>com.aventstack</groupId>
                <artifactId>extentreports</artifactId>
                <version>3.0.6</version>
            </dependency>
            <dependency>
                <groupId>com.paulhammant</groupId>
                <artifactId>ngwebdriver</artifactId>
                <version>0.9.6</version>
                <!-- <scope>test</scope> -->
            </dependency>       
            <!-- CodeModel -->
            <dependency>
                <groupId>com.sun.codemodel</groupId>
                <artifactId>codemodel</artifactId>
                <version>${codemodel.version}</version>
                <scope>compile</scope>
            </dependency>
    
            <!-- Commons Lang3 -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${commons-lang3.version}</version>
            </dependency>
    
            <!-- Gson -->
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
            </dependency>
    
            <!-- JUnit -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
            </dependency>
    
            <!-- Lambdaj -->
            <dependency>
                <groupId>com.googlecode.lambdaj</groupId>
                <artifactId>lambdaj</artifactId>
                <version>${lambdaj.version}</version>
            </dependency>
    
            <!-- Logback -->
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${logback.version}</version>
            </dependency>
    
            <!-- Selenium Java -->
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>${selenium.version}</version>
            </dependency>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
                <version>${selenium.version}</version>
            </dependency>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-api</artifactId>
                <version>${selenium.version}</version>
            </dependency>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>htmlunit-driver</artifactId>
                <version>${htmlunit-driver.version}</version>
            </dependency>
            <dependency>
                <groupId>net.sourceforge.htmlunit</groupId>
                <artifactId>htmlunit</artifactId>
                <version>${htmlunit-driver.version}</version>
            </dependency>
            <dependency>
                <groupId>com.codeborne</groupId>
                <artifactId>phantomjsdriver</artifactId>
                <version>${phantomjsdriver.version}</version>
            </dependency>
    
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>${maven-release-plugin.version}</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <useReleaseProfile>false</useReleaseProfile>
                        <releaseProfiles>release</releaseProfiles>
                        <indentSize>4</indentSize>
                        <goals>deploy</goals>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>${nexus-staging-maven-plugin.version}</version>
                    <extensions>true</extensions>
                    <configuration>
                        <serverId>ossrh</serverId>
                        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                </plugin>
    
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <compilerVersion>1.8</compilerVersion>
                        <source>1.8</source>
                        <target>1.8</target>
                        <compilerArgument>-proc:none
                        </compilerArgument>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>com.github.webdriverextensions</groupId>
                    <artifactId>webdriverextensions-maven-plugin</artifactId>
                    <version>${webdriverextensions-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>install-drivers</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <drivers>
                            <driver>
                                <name>internetexplorerdriver</name>
                                <version>3.4.0</version>
                            </driver>
                            <driver>
                                <name>edgedriver</name>
                                <version>4.15063</version>
                            </driver>
                            <driver>
                                <name>chromedriver</name>
                                <version>2.29</version>
                            </driver>
                            <driver>
                                <name>geckodriver</name>
                                <version>0.16.0</version>
                            </driver>
                            <!-- 
                            <driver>
                                <name>phantomjs</name>
                                <version>2.1.1</version>
                            </driver>
                             -->
                        </drivers>
                    </configuration>
                </plugin>
            </plugins>
            <pluginManagement>
                <plugins>
                    <!--This plugin's configuration is used to store Eclipse m2e settings 
                        only. It has no influence on the Maven build itself. -->
                    <plugin>
                        <groupId>org.eclipse.m2e</groupId>
                        <artifactId>lifecycle-mapping</artifactId>
                        <version>1.0.0</version>
                        <configuration>
                            <lifecycleMappingMetadata>
                                <pluginExecutions>
                                    <pluginExecution>
                                        <pluginExecutionFilter>
                                            <groupId>com.github.webdriverextensions</groupId>
                                            <artifactId>webdriverextensions-maven-plugin</artifactId>
                                            <versionRange>[1.0,)</versionRange>
                                            <goals>
                                                <goal>install-drivers</goal>
                                            </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                            <execute>
                                                <runOnConfiguration>true</runOnConfiguration>
                                                <runOnIncremental>true</runOnIncremental>
                                            </execute>
                                        </action>
                                    </pluginExecution>
                                    <pluginExecution>
                                        <pluginExecutionFilter>
                                            <groupId>org.bsc.maven</groupId>
                                            <artifactId>maven-processor-plugin</artifactId>
                                            <versionRange>[2.2.4,)</versionRange>
                                            <goals>
                                                <goal>process-test</goal>
                                            </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                            <execute>
                                                <runOnConfiguration>true</runOnConfiguration>
                                                <runOnIncremental>true</runOnIncremental>
                                            </execute>
                                        </action>
                                    </pluginExecution>
                                    <pluginExecution>
                                        <pluginExecutionFilter>
                                            <groupId>org.codehaus.mojo</groupId>
                                            <artifactId>build-helper-maven-plugin</artifactId>
                                            <versionRange>[1.9.1,)</versionRange>
                                            <goals>
                                                <goal>add-test-source</goal>
                                            </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                            <ignore />
                                        </action>
                                    </pluginExecution>
                                </pluginExecutions>
                            </lifecycleMappingMetadata>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>    
    </project>
    

    感谢您的关注和解决方案。

0 个答案:

没有答案