It looks like You have more than one org.json:json dependency on your classpath.

Looking at it:
org.springframework.boot:spring-boot-starter-test depends on
com.jayway.jsonpath:json-pathwhich in turn brings
org.json:json which is much older than your version (v. 20140107)

You could try excluding this transitive dependency from spring-boot-starter-test:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </exclusion>
    </exclusions>
</dependency>

... but it's possible that there is something within json-path which depends on something from the older json library, which is no longer in the newer version, so proceed with caution and test everything thoroughly.

There is also a chance that something else brings org.json:json.

To verify, please run mvn dependency:tree and search in the produced output for org.json:json.

Answer from diginoise on Stack Overflow
🌐
Maven Repository
mvnrepository.com › artifact › org.springframework.boot › spring-boot-starter-json
Maven Repository: org.springframework.boot » spring-boot-starter-json
1 month ago - JSON Libraries · Java Specifications · Core Utilities · Mocking · Annotation Libraries · Web Assets · HTTP Clients · Logging Bridges · Dependency Injection · XML Processing · Concurrency Libraries · Web Frameworks · Android Platform · Code Generators · View All · Home » org.springframework.boot » spring-boot-starter-json ·
🌐
Maven Central Repository
search.maven.org › org.springframework.boot › spring-boot-starter-json › 2.2.3.release
spring-boot-starter-json
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>2.2.3.RELEASE</version> </dependency> Copy to clipboard ·
🌐
Maven Central
central.sonatype.com › artifact › org.springframework.boot › spring-boot-starter-json
spring-boot-starter-json - Maven Central - Sonatype
pkg:maven/org.springframework.boot/spring-boot-starter-json@Loading... ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>4.1.0-M2</version> </dependency>
🌐
Medium
medium.com › @abdullahkhames96 › understanding-jackson-in-spring-boot-a-comprehensive-guide-c6424d9443f6
jsonUnderstanding Jackson in Spring Boot: A Comprehensive Guide | by Abdullah khames | Medium
October 25, 2024 - The Jackson library is modular, and Spring Boot uses it by default in its spring-boot-starter-web and spring-boot-starter-json dependencies.
Top answer
1 of 2
5

Spring Boot's auto-configuration for Jackson requires spring-web as it's the Spring Framework module that contains the infrastructure for configuring and creating a Jackson ObjectMapper. If you really don't want a spring-web dependency in your application, you could replace the dependency on spring-boot-starter-json with a direct dependency on Jackson instead, however you will then have to configure and create the ObjectMapper yourself as Spring Boot will no longer do it for you.

2 of 2
1

I created a custom jackson standalone configuration.

It only contains what I need, but you could easily copy the bits in the JacksonAutoConfiguration for the jacksonProperties or anything else that you need and add them here. And then remove the JacksonAutoConfiguration class and use the code snippet below.

I just wanted to keep it simple because mine was for a redis synchronization service.

The optimal solution would be to rewrite the code in JacksonAutoConfiguration and drop the Jackson2ObjectMapper and use JsonMapper.builder() instead and then they could drop the spring-web dependency entirely.

@Configuration
public class JacksonStandaloneConfiguration {

    @Bean
    public ObjectMapper jacksonOjectMapper(ObjectProvider<Module> provider) {
        // All modules declared as beans anywhere else
        List<Module> modulesToInstall = provider.stream().toList();
        Builder builder = JsonMapper.builder();
        ObjectMapper mapper = configure(builder);
        registerModules(mapper, modulesToInstall);
        return mapper;
    }

    private ObjectMapper configure(Builder builder) {
        return builder //
                // Spring boot defaults
                .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) //
                .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) //
                // Jackson2ObjectMapperBuilder defaults
                .disable(MapperFeature.DEFAULT_VIEW_INCLUSION) //
                .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) //
                .build();
    }

    private static void registerModules(ObjectMapper mapper, List<Module> modulesToInstall) {
        MultiValueMap<Object, Module> modulesToRegister = new LinkedMultiValueMap<>();
        registerWellKnownModulesIfAvailable(modulesToRegister);
        modulesToInstall.forEach(module -> registerModule(module, modulesToRegister));
        List<Module> modules = new ArrayList<>();
        for (List<Module> nestedModules : modulesToRegister.values()) {
            modules.addAll(nestedModules);
        }
        mapper.registerModules(modules);
    }

    private static void registerWellKnownModulesIfAvailable(MultiValueMap<Object, Module> modulesToRegister) {
        // Jackson2ObjectMapperBuilder defaults (You could add these as beans and remove this method entirely)
        registerModule(new Jdk8Module(), modulesToRegister);
        registerModule(new JavaTimeModule(), modulesToRegister);
//      registerModule(new JodaModule(), modulesToRegister);
//      registerModule(new KotlinModule(), modulesToRegister);
    }

    private static void registerModule(Module module, MultiValueMap<Object, Module> modulesToRegister) {
        if (module.getTypeId() == null) {
            modulesToRegister.add(SimpleModule.class.getName(), module);
        } else {
            modulesToRegister.set(module.getTypeId(), module);
        }
    }

}
Top answer
1 of 6
198

Add under

 <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>

The following exclusion:

 <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
        </exclusion>
    </exclusions>

Similarly, for Gradle projects:

testCompile("org.springframework.boot:spring-boot-starter-test") {
    exclude group: "com.vaadin.external.google", module:"android-json"
}
2 of 6
47

Background: org.json works great, but has a license clause that some people don't like ("The Software shall be used for Good, not Evil."). So Vaadin wanted to use the library, but couldn't be sure they wouldn't use it for evil someday. Instead, they re-implemented the interface, published android-json and used it as a drop in replacement for org.json. Others began to use android-json as well so that they too would not be bound by the requirement of not using their software for evil.

This is a fine solution, except that when the two libraries are on the classpath, they collide.

Solution: If you get this error from conflicting transitive dependencies, then your best bet is to exclude either Vaadin's android-json library (brought in by Spring), or exclude the org.json library (brought in by another dependency). Vaadin's version is meant to be an identical implementation, but there are subtle differences.

If you're using org.json in your code and it is conflicting with Spring's Vaadin dependency, then I would recommend trying open-json. It's a port of Vaadin's re-implementation of org.json, but they changed the packages so you won't have any conflicts with org.json:json or com.vaadin.external.google:android-json

https://github.com/openjson/openjson

Add gradle dependency:

    implementation('com.github.openjson:openjson:1.0.12')

Or in Maven:

    <dependency>
        <groupId>com.github.openjson</groupId>
        <artifactId>openjson</artifactId>
        <version>1.0.12</version>
    </dependency>

Then update any imports that were being used by org.json classes.

Find elsewhere
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 41201
The "spring-boot-starter-test" package:3.1.5" carries with it an incomplete implementation of the "json" library, which leads to an error in runtime · Issue #41201 · spring-projects/spring-boot
June 21, 2024 - The "spring-boot-starter-test:3.1.5" there is a dependency on the library "jsonassert:1.5.1" which in turn has a dependency on the library "android-json:0.0.20131108.vaadin1". The latter contains its own implementation of the "json" libr...
Author   Nphox
🌐
Maven Repository
mvnrepository.com › artifact › org.springframework.boot › spring-boot-starter-json › 2.4.1
Maven Repository: org.springframework.boot » spring-boot-starter-json » 2.4.1
December 11, 2020 - Starter for reading and writing JSON · LicenseApache 2.0 · Tagsjsonspringframeworkstarter · Organization Pivotal Software, Inc. HomePage https://spring.io/projects/spring-boot 🔍 Inspect URL · Links · DateDec 11, 2020 · Filespom (3 KB)jar (4 KB)View All · RepositoriesCentralCloudera PubMulesoftSpring ReleasesTerrestrisWSO2 Public+3 more · Ranking · #906in MvnRepository · Vulnerabilities · Vulnerabilities from dependencies: CVE-2024-38820CVE-2024-38809CVE-2024-22262CVE-2024-22259CVE-2024-22243CVE-2022-42004CVE-2022-42003CVE-2021-46877CVE-2021-22118CVE-2020-36518CVE-2016-1000027View 8 more ...
🌐
Spring
docs.spring.io › spring-boot › reference › features › json.html
JSON :: Spring Boot
Auto-configuration for Jackson 3 is provided and Jackson is part of spring-boot-starter-json. When Jackson is on the classpath a JsonMapper bean is automatically configured.
🌐
ZetCode
zetcode.com › springboot › json
Spring Boot JSON - serving JSON data in a Spring Boot annotation
July 28, 2023 - It allows to read and write data in JSON, Avro, BSON, CBOR, CSV, Smile, (Java) Properties, Protobuf, XML or YAML format. Jackson is auto-configured. It comes with the spring-boot-starter-json. When Jackson is on the classpath an ObjectMapper bean is automatically configured.
🌐
Spring
docs.spring.io › spring-boot › reference › using › build-systems.html
Build Systems :: Spring Boot
You get a one-stop shop for all the Spring and related technologies that you need without having to hunt through sample code and copy-paste loads of dependency descriptors. For example, if you want to get started using Spring and JPA for database access, include the spring-boot-starter-data-jpa dependency in your project.
🌐
GeeksforGeeks
geeksforgeeks.org › advance java › spring-boot-consuming-and-producing-json
Spring Boot - Consuming and Producing JSON - GeeksforGeeks
January 16, 2026 - Note: Spring Boot uses Jackson ObjectMapper internally to convert between Java objects and JSON. Create a project folder SpringApplication. Add these two Gradle files. ... plugins { id 'org.springframework.boot' version '3.3.2' id 'io.spring.dependency-management' version '1.1.3' id 'java' } group = 'com.app' version = '0.0.1-SNAPSHOT' java { sourceCompatibility = JavaVersion.VERSION_17 } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
🌐
Baeldung
baeldung.com › home › spring › spring boot › intro to spring boot starters
Intro to Spring Boot Starters | Baeldung
August 3, 2025 - Spring Boot will figure out what version to use – all you need to specify is the version of spring-boot-starter-parent artifact. If later on you need to upgrade the Boot library and dependencies, just upgrade the Boot version in one place and it will take care of the rest.
🌐
HowToDoInJava
howtodoinjava.com › home › spring boot 2 › gson with spring boot: dependency and example
Gson with Spring Boot: Dependency and Example
September 5, 2023 - If we want to exclude Jackson completely from application runtime, we can do it by exluding spring-boot-starter-json. <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- Exclude the default Jackson dependency --> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> </dependencies> If we want to exclude Jackson only through the spring boot configuration, we can exclude it by disabling its auto configuration class JacksonAutoConfiguration.
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 9248
NoSuchMethodError when using spring-boot-starter-test due to transitive dependency on incomplete clean room implementation of org.json:json · Issue #9248 · spring-projects/spring-boot
May 17, 2017 - NoSuchMethodError when using spring-boot-starter-test due to transitive dependency on incomplete clean room implementation of org.json:json#9248
Published   May 17, 2017
Author   scottishWill
🌐
DEV Community
dev.to › alexmercedcoder › how-to-build-a-java-spring-json-api-from-a-blank-maven-project-311m
How to build a Java Spring JSON API from a blank maven project - DEV Community
October 1, 2023 - <dependencies> <!-- Spring Boot Starter --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Spring Boot Starter Data JPA --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <!-- PostgreSQL Driver --> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.14</version> </dependency> </dependencies>
🌐
GeeksforGeeks
geeksforgeeks.org › springboot › spring-boot-starters
Spring Boot - Starters - GeeksforGeeks
2 weeks ago - No need to remember the name and version of the dependencies. ... This single dependency includes Hibernate, Spring Data JPA, transaction management, and other required libraries automatically.