Spring 2.0.0-迁移给出错误:NoClassDefFoundError:com/jayway/jsonpath/spi/mapper/JacksonMappingProvider

Spring 2.0.0-迁移给出错误:NoClassDefFoundError:com/jayway/jsonpath/spi/mapper/JacksonMappingProvider,spring,spring-boot,Spring,Spring Boot,将我的Spring Boot 1.4.3版本应用程序迁移到Spring Boot 2.0.0时。我得到这个错误: NoClassDefFoundError: com/jayway/jsonpath/spi/mapper/JacksonMappingProvider Spring引导父级具有2.0.0版本。jsonpath jayway具有2.2.0版本 对于我使用的Jsonpath。我想扫描JSON的一部分,而不是将整个JSON字符串映射到对象。。。在这种情况下 import net.minid

将我的Spring Boot 1.4.3版本应用程序迁移到Spring Boot 2.0.0时。我得到这个错误:

NoClassDefFoundError: com/jayway/jsonpath/spi/mapper/JacksonMappingProvider

Spring引导父级具有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——SpringBoot2.0.0的json路径至少需要2.4.0版本,请参见下文
  • 在将源部件升级到SpringBoot2.0.0时,我忘记删除SpringBootStarter测试的旧版本规范 我的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>
    
    
    
    作为SpringBoot2.0.0.RELEASE的一部分,要使用的json路径版本是
    2.4.0

       <dependency>
          <groupId>com.jayway.jsonpath</groupId>
          <artifactId>json-path</artifactId>
          <version>2.4.0</version>
        </dependency>
    
    
    com.jayway.jsonpath
    json路径
    2.4.0
    
    spring boot测试依赖性如何?跳过测试时?Jsonpath是spring boot starter测试的一部分,不是吗?您是否需要明确定义的其他用途?是的,我使用以下类:import net.minidev.json.JSONArray;导入net.minidev.json.JSONObject;导入net.minidev.json.JSONValue;正如我在pom spring boot 2.0.0.RELEASE中检查的那样。提到的json路径是
    2.4.0
    。你能把它改成2.4.0再试试吗?