这个警告提示你的类路径上找到了多个 'org.json.JSONObject' 类的出现,可能会导致运行时行为不可预测。为了解决这个警告,你可以在 Maven 的 pom.xml 文件或 Gradle 的 build.gradle 文件中添加一个排除(exclude)依赖项的配置,例如:

Maven:

<dependency>
    <groupId>com.example</groupId>
    <artifactId>example-artifact</artifactId>
    <version>1.0.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Gradle:

dependencies {
    // ...
    implementation('com.example:example-artifact:1.0.0') {
        exclude group: 'org.json', module: 'json'
    }
}

这将排除掉 'org.json:json' 依赖项,确保只有你需要的 'org.json.JSONObject' 类被加载。

解决 'Found multiple occurrences of org.json.JSONObject' 警告

原文地址: https://www.cveoy.top/t/topic/oDpO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录