' com.google.common.collect.Lists'的ClassNotFoundException

时间:2018-04-18 15:08:31

标签: java spring guava noclassdeffounderror

我为我的项目构建了一个基于spring boot的jar。一旦我启动某个功能,我就会遇到以下异常:

  

SEVERE:servlet [dispatcherServlet]的Servlet.service()与path []的上下文抛出异常[Handler dispatch failed;嵌套异常是java.lang.NoClassDefFoundError:com / google / common / collect / Lists]的根本原因   java.lang.ClassNotFoundException:com.google.common.collect.Lists

我已经在我的家属中添加了番石榴:

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>19.0</version>
    </dependency>

还尝试了其他版本,如23.6-jre和24.1-jre,但似乎没有任何工作..

我的代码中出现的异常是在使用

return Lists.reverse(myList);

此时我不知道可能出现什么问题,我非常感谢任何帮助!

编辑:

当我尝试时    mvn安装 我收到以下错误消息:

  

[INFO]扫描项目......   [错误] [错误]处理POM时遇到一些问题:   [错误]&#39; build.plugins.plugin.version&#39;对于org.apache.maven.plugins:maven-assembly-plugin必须是有效的版本,但是要发布&#39; RELEASE&#39;。 @第85行,第26栏    @   [错误]构建无法读取1个项目 - &gt; [帮助1]   [错误]   [错误]项目com.boot.backend:AyMaps:0.0.1-SNAPSHOT(C:\ Users \\ Documents \ GitHub \ AyMaps \ pom.xml)有1个错误   [错误]&#39; build.plugins.plugin.version&#39;对于org.apache.maven.plugins:maven-assembly-plugin必须是有效的版本,但是要发布&#39; RELEASE&#39;。 @第85行,第26栏   [错误]   [错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。   [ERROR]使用-X开关重新运行Maven以启用完整的调试日志记录。   [错误]   [错误]有关错误和可能解决方案的更多信息,请阅读以下文章:   [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

这是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0

<groupId>com.boot.backend</groupId>
<artifactId>AyMaps</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Routenplaner für OSM-Daten</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<repositories>
    <repository>
        <id>Topobyte</id>
        <url>http://mvn.topobyte.de</url>
    </repository>
</repositories>

<dependencies>
    <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>24.1-jre</version>
    </dependency>
    <dependency>
        <groupId>de.topobyte</groupId>
        <artifactId>osm4j-pbf</artifactId>
        <version>0.0.10</version>
    </dependency>
    <dependency>
        <groupId>de.topobyte</groupId>
        <artifactId>osm4j-utils</artifactId>
        <version>0.0.23</version>
    </dependency>
    <dependency>
        <groupId>de.topobyte</groupId>
        <artifactId>osm4j-core</artifactId>
        <version>0.0.20</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>RELEASE</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>com.boot.backend.GeoController</mainClass>
                    </manifest>
                </archive>
                <addResources>true</addResources>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>

            </configuration>
            <executions>
                <execution>
                    <id>assemble-all</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

0 个答案:

没有答案