测试项目中警告
Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/D:/apache-maven-3.6/testsoft/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class jar:file:/D:/apache-maven-3.6/testsoft/org/json/json/20170516/json-20170516.jar!/org/json/JSONObject.class
原因是在spring-boot-starter-test拉入“ android-json”(com.vaadin.external.google)
解决方法是:
在 配置 文件中 把对应的jar包依赖忽略掉即可
dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-redis' compileOnly 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' developmentOnly 'org.springframework.boot:spring-boot-devtools' // implementation 'org.springframework.boot:spring-boot-starter-log4j2' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' exclude group: 'com.vaadin.external.google', module: 'android-json' } implementation 'org.jsoup:jsoup:1.10.3' implementation 'org.json:json:20190722' }