메이븐 + 스프링 부트:org.json이 여러 개 발견되었습니다.클래스 경로의 JSONObject:
내가 달릴 때mvn test이 경고를 받았어요.어떻게 하면 고칠 수 있죠?
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에 대한 유일한 참조는
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
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 프로젝트의 경우:
testCompile("org.springframework.boot:spring-boot-starter-test") {
exclude group: "com.vaadin.external.google", module:"android-json"
}
배경:org.json는 훌륭하게 동작하지만, 일부에서는 마음에 들지 않는 라이센스 조항(「소프트웨어는 악이 아닌 선을 위해 사용됩니다.」)이 있습니다.그래서 바딘은 도서관을 이용하고 싶었지만 언젠가 그들이 도서관을 악에 이용하지 않을 것이라고 확신할 수 없었다.대신에, 인터페이스를 재실장해, 공개했습니다.android-json대체품으로 사용했어요org.json다른 사람들이 사용하기 시작했다.android-json또, 악에 대해서 소프트웨어를 사용하지 않는 요구에 구속되지 않게 하기 위해서도.
이것은 훌륭한 해결책입니다만, 2개의 라이브러리가 클래스 패스에 있을 때는 충돌합니다.
솔루션:경합하는 전이 의존관계로 인해 이 오류가 발생하는 경우 Vaadin 중 하나를 제외하는 것이 가장 좋습니다.android-json라이브러리(봄에 의해 제공됨) 또는 제외org.json라이브러리(다른 종속성에 의해 로그인)Vaadin의 버전은 동일한 구현을 의도하고 있지만 미묘한 차이가 있습니다.
사용하시는 경우org.json당신의 코드와 그것은 스프링의 Vaadin 의존관계와 상충된다, 그리고 나는 그것을 시도해 볼 것을 추천한다.open-json바딘의 재이행 항구입니다.org.json패키지가 변경되어 있는 경우는, 와의 경합이 발생하지 않게 됩니다.org.json:json또는com.vaadin.external.google:android-json
https://github.com/openjson/openjson
그라들 종속성 추가:
implementation('com.github.openjson:openjson:1.0.12')
또는 메이븐:
<dependency>
<groupId>com.github.openjson</groupId>
<artifactId>openjson</artifactId>
<version>1.0.12</version>
</dependency>
그런 다음 에서 사용하던 모든 Import를 업데이트합니다.org.json반.
그래들 프로젝트의 경우 아래 줄을 추가하십시오.
testCompile('org.springframework.boot:spring-boot-starter-test'){
exclude group: "com.vaadin.external.google", module:"android-json"
}
이 방법은 효과가 있었습니다.
configurations {
testImplementation.exclude group: 'com.vaadin.external.google', module: 'android-json'
}
승인된 답변에 기반한 그라들 코틀린 DSL 버전
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude (
group = "com.vaadin.external.google",
module = "android-json"
)
}
제외할 수 있습니다.android-json에서 모듈화하다.testImplementation.
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: "com.vaadin.external.google", module:"android-json"
}
언급URL : https://stackoverflow.com/questions/52980064/maven-spring-boot-found-multiple-occurrences-of-org-json-jsonobject-on-the-cl
'programing' 카테고리의 다른 글
| ajax를 사용하여 wordpress 설정 api 옵션을 저장하는 중, (0) | 2023.03.02 |
|---|---|
| Wordpress에서 페이지 제목을 가져오는 방법 (0) | 2023.03.02 |
| 세션 타임아웃 및 View ExpiredJSF/PrimeFaces ajax 요청에 대한 예외 처리 (0) | 2023.03.02 |
| Json.net의 늘필드 무시 (0) | 2023.03.02 |
| React Hook useEffect에 종속성이 누락되었습니다. '리스트' (0) | 2023.03.02 |