Maven + Spring Boot:在类路径中发现了多次org.json.JSONObject: [英] Maven + Spring Boot: Found multiple occurrences of org.json.JSONObject on the class path:

查看:889
本文介绍了Maven + Spring Boot:在类路径中发现了多次org.json.JSONObject:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行mvn test时,得到此警告.我该如何解决?

When I run mvn test I get this warning. How can I fix it?

Found multiple occurrences of org.json.JSONObject on the class path:

        jar:file:/C:/Users/Chloe/.m2/repository/org/json/json/20140107/json-20140107.jar!/org/json/JSONObject.class
        jar:file:/C:/Users/Chloe/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class

You may wish to exclude one of them to ensure predictable runtime behavior

这是我的 pom.xml . JSON的唯一参考是

Here is my pom.xml. The only reference to JSON is

    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
    </dependency>

Apache Maven 3.5.3

Apache Maven 3.5.3

推荐答案

添加到

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

以下排除:

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

类似地,对于Gradle项目:

Similarly, for Gradle projects:

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

这篇关于Maven + Spring Boot:在类路径中发现了多次org.json.JSONObject:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆