spring - Spring 2.0.0 - 迁移给出错误:NoClassDefFoundError: com/jayway/jsonpath/spi/mapper/JacksonMappingProvider
问题描述
将我的 Spring Boot 1.4.3-release 应用程序迁移到 Spring Boot 2.0.0 时。我收到此错误:
NoClassDefFoundError:com/jayway/jsonpath/spi/mapper/JacksonMappingProvider
Spring Boot Parent 具有 2.0.0. jsonpath jayway 有 2.2.0 版本。
对于我使用的 Jsonpath。我想扫描部分 JSON,而不是将整个 json 字符串映射到对象......在这种情况下。
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import net.minidev.json.JSONValue;
我做错了什么?
已解决:有两个问题:
- 感谢@Barath,见下文——Spring Boot 2.0.0 的 json-path 至少需要 2.4.0 版本。
- 在将源代码部分升级到 Spring Boot 2.0.0 时,我忘记删除 spring-boot-starter-test 的旧版本规范。
我的 pom.xml 是:
<project xmlns="http://maven.apache.org/POM/4.0.0"
standard init
<!-- Use parent POM.xml -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-jaxb2-plugin.version>0.13.3</maven-jaxb2-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</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-data-jpa</artifactId>
</dependency>
<!-- Chat websocket stuff -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-reactor-netty</artifactId>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<!-- Database for Openshift -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
<!-- JSON path -->
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<!--<version>1.9</version>-->
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<!--<version>4.2.3.RELEASE</version>-->
</dependency>
<!-- TESTING -->
</dependencies>
<build>
<finalName>geosolutions</finalName>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build Angular production code</id>
<goals>
<goal>exec</goal>
</goals>
<phase>compile</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
<argument>--prod</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- for testing -->
<...>
</plugins>
</build>
</project>
解决方案
作为 Spring-Boot 2.0.0.RELEASE 的一部分,要使用的 json-path 版本是2.4.0
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
推荐阅读
- javascript - 突出显示 div 中的元素并将其设置在其他元素之上
- clearcase - 如何将 clearcase 视图从 v7.3 迁移到 v9.0.x?
- javascript - 如何用另一个替换div元素中的同一行 - javascript
- java - 如何通过 asyncTask 从不同的 URL 下载不同文件夹中的文件?
- python - Python:如何用字符串和数字重命名列
- smali - dexlib2 - 分支覆盖检测
- matlab - Imwarp 图像 Simulink Matlab 功能块可变大小
- python-3.x - Hyperopt:重新运行时更改最佳参数
- r - 是否可以通过管道传输数据框变量
- android - 如何在 Flutter 中直接拨打电话