添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Spring 2.0.0 - migrate gives error: NoClassDefFoundError: com/jayway/jsonpath/spi/mapper/JacksonMappingProvider

Ask Question

When migrating my Spring Boot 1.4.3-release application to Spring Boot 2.0.0. I get this error:

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

The Spring Boot Parent has the 2.0.0. The jsonpath jayway has the 2.2.0 version.

For the Jsonpath I use. I want to scan parts of the JSON, not map the whole json string to objects ... in this case.

import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import net.minidev.json.JSONValue;

What I am doing wrong?

SOLVED: there were 2 issues:

  • See below thanks to @Barath -- json-path for Spring Boot 2.0.0 needs at least the 2.4.0 version.
  • While upgrading the source part to Spring Boot 2.0.0 I forgot to remove the older version specification for the spring-boot-starter-test.
  • My pom.xml is:

    <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>
                    Jsonpath comes as part of spring boot starter test isn't it ? Do you require for some other purpose as you defined explicitly ?
    – Barath
                    Oct 20, 2018 at 19:11
                    Yes, I use these classes: import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import net.minidev.json.JSONValue;
    – tm1701
                    Oct 20, 2018 at 19:14
                    As I checked in pom spring boot 2.0.0.RELEASE. json path mentioned is   <json-path.version>2.4.0</json-path.version>. can you change it to 2.4.0 and try ?
    – Barath
                    Oct 20, 2018 at 19:15
          <groupId>com.jayway.jsonpath</groupId>
          <artifactId>json-path</artifactId>
          <version>2.4.0</version>
        </dependency>
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.