Maven | java.lang.NoClassDefFoundError:com / google / common / base / Strings

时间:2018-06-10 05:51:44

标签: java maven apache-nifi

我正在尝试编译我的maven java项目,但它未能找到Guava依赖项。下面是即将到来的maven异常。

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:264)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
        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:497)
        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

我的Pom文件

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>18.0</version>
</dependency>
                <dependency>
                        <groupId>org.apache.nifi</groupId>
                        <artifactId>nifi-api</artifactId>
                </dependency>

                <dependency>
                        <groupId>com.fasterxml.jackson.dataformat</groupId>
                        <artifactId>jackson-dataformat-csv</artifactId>
                        <version>2.7.3</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.nifi</groupId>
                        <artifactId>nifi-processor-utils</artifactId>
                        <version>1.1.0</version>
                </dependency>
                <dependency>
                        <groupId>commons-codec</groupId>
                        <artifactId>commons-codec</artifactId>
                        <version>1.10</version>
                </dependency>

                <dependency>
                        <groupId>com.fasterxml.jackson.dataformat</groupId>
                        <artifactId>jackson-dataformat-xml</artifactId>
                        <version>2.7.3</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-csv</artifactId>
                        <version>1.4</version>
                </dependency>




                <dependency>
                        <groupId>org.apache.nifi</groupId>
                        <artifactId>nifi-utils</artifactId>
                </dependency>
                <dependency>
                        <groupId>org.apache.nifi</groupId>
                        <artifactId>nifi-mock</artifactId>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-simple</artifactId>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <scope>test</scope>
                </dependency>
        </dependencies>


        <build>
                <sourceDirectory>src</sourceDirectory>
                        <plugins>
                        <plugin>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <version>3.5.1</version>
                                <configuration>
                                        <source>1.8</source>
                                        <target>1.8</target>
                                </configuration>
                        </plugin>
                </plugins>
        </build>

1 个答案:

答案 0 :(得分:0)

在nar项目中添加这些依赖项。