[SpringBoot] 스프링부트 메이븐 빌드 시 Found multiple occurrences 오류
스프링부트에서 메이븐 빌드 시 아래처럼 Found multiple occurrences 오류가 발생하며 BUILD FAILURE 되는 경우.
사용한 라이브러리에 따라 세부적인 오류내용은 다를 수 있다.
|
Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/C:/Users/gendev/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class jar:file:/C:/Users/gendev/.m2/repository/org/json/json/20200518/json-20200518.jar!/org/json/JSONObject.class You may wish to exclude one of them to ensure predictable runtime behavior |
아래처럼 org.json 을 pom.xml 에 추가한 이후로 오류가 발생하게 됐다.
|
<!– https://mvnrepository.com/artifact/org.json/json –> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20200518</version> </dependency> |
동일한 클래스명이 발견되어 충돌한 것으로 보인다.
메이븐 빌드 시 사용하지 않는 클래스가 속한 패키지를 제외시켜야 한다.
pom.xml 을 아래와 같이 수정했다.
[AS-iS]
|
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> |
[TO-BE]
|
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>com.vaadin.external.google</groupId> <artifactId>android-json</artifactId> </exclusion> </exclusions> </dependency> |
이후 빌드에 성공했다.