關(guān)于Maven依賴沖突解決之exclusions
Maven依賴沖突解決之exclusions
1. 背景
- 作為java生態(tài)下開發(fā)者,往往需要使用大量線程的第三方庫,一般都是以jar包形式存在。
- maven作為事實上主流的jar包依賴管理工具,Idea和Eclipse都支持創(chuàng)建maven工程來管理jar包依賴。
- 使用maven進行jar包依賴管理時,maven會自行管理jar包及其依賴鏈條,但往往會遇到依賴沖突問題,這時候就可以嘗試使用exclusion來進行依賴管理。
2. 解決方式
場景
假如hadoop集群中hadoop版本是3.2.1,這時候為了保證程序能夠順利操作hadoop,需要引入hadoop-client的3.2.1版本。但這里也可以看到,spark-core_2.12內(nèi)部也有對hadoop-client的依賴,而且版本是低版本的2.7.4,這時候往往就會產(chǎn)生沖突或者未知錯誤。所以需要使用exclusions做依賴排除。
解決方式
使用exclusions來對某一個第三方庫引入的依賴jar包做排除
<dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_2.12</artifactId> <version>${spark.version}</version> <exclusions> <exclusion> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> </exclusion> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency>
Maven解決依賴沖突總結(jié)
如果存在jar包的依賴沖突,在項目啟動時總是報類似這樣的錯:NoSuchMethodError、ClassNotFoundException、成員變量找不到等等。真的很讓人不好受。
Maven采用的是“最近獲勝的策略”來處理依賴的沖突,即如果一個項目最終依賴于相同artifact的多個版本,在依賴樹中離項目最近的那個版本將被使用。讓我們來看看一個實際的例子。
實例分析
我們有一個web應(yīng)用resolve-web,該工程依賴于project-A和project-B,project-A依賴于project-common的1.0版本并調(diào)用其中的sayHello()方法。project-B依賴于project-C,而project-C又進一步依賴于project-common的2.0版本并調(diào)用其中的sayGoodBye()方法。project-common的1.0和2.0版本是不同的,1.0中之包含sayHello()方法,而2.0中包含了sayHello()和sayGoodBye()兩個方法。整個項目的依賴關(guān)系如下圖:
根據(jù)Maven的最近原則依賴機制,resolve-web將同時依賴于project-common的1.0和2.0版本,這就造成了依賴沖突。而根據(jù)最近獲勝策略,Maven將選擇project-common的1.0版本作為最終的依賴。這和Gradle不同,Gradle在默認(rèn)情況下將選擇最新的版本作為獲勝版本。而對于Maven,由于proejct-common的1.0版本比2.0版本在依賴樹中離resolve-web更近,故1.0版本獲勝。在resolve-web中執(zhí)行"mvn dependency:tree -Dverbose"可以看到resolve-web的依賴關(guān)系:
[INFO] resolve-web:resolve-web:war:1.0-SNAPSHOT [INFO] +- junit:junit:jar:3.8.1:test [INFO] +- project-B:project-B:jar:1.0:compile [INFO] | \- project-C:project-C:jar:1.0:compile [INFO] | \- (project-common:project-commmon:jar:2.0:compile - omitted for conflict with 1.0) [INFO] +- project-A:project-A:jar:1.0:compile [INFO] | \- project-common:project-commmon:jar:1.0:compile [INFO] \- javax.servlet:servlet-api:jar:2.4:provided
由上可知,project-common:project-commmon:jar:2.0被忽略掉了。此時在resolve-web的war包中將只包含project-common的1.0版本,于是問題來了。由于project-common的1.0版本中不包含sayGoodBye()方法,而該方法正是project-C所需要的,所以運行時將出現(xiàn)“NoSuchMethodError”。
解決辦法
方法1:顯式加入對project-common 2.0版本的依賴。先前的2.0版本不是離resolve-web遠(yuǎn)了點嗎,那我們就直接將它作為resolve-web的依賴,這不就比1.0版本離resolve-web還近嗎?在resove-web的pom.xml文件中直接加上對project-common 2.0 的依賴
<dependency> <groupId>project-common</groupId> <artifactId>project-commmon</artifactId> <version>2.0</version> </dependency>
方法2:resolve-web對project-A的dependency聲明中,將project-common排除掉。在resolve-web的pom.xml文件中修改對project-A的dependency聲明
<dependency> <groupId>project-A</groupId> <artifactId>project-A</artifactId> <version>1.0</version> <exclusions> <exclusion> <groupId>project-common</groupId> <artifactId>project-commmon</artifactId> </exclusion> </exclusions> </dependency>
此時再在resolve-web中執(zhí)行"mvn dependency:tree -Dverbose",如下:
...... [INFO] resolve-web:resolve-web:war:1.0-SNAPSHOT [INFO] +- junit:junit:jar:3.8.1:test [INFO] +- project-B:project-B:jar:1.0:compile [INFO] | \- project-C:project-C:jar:1.0:compile [INFO] | \- project-common:project-commmon:jar:2.0:compile [INFO] +- project-A:project-A:jar:1.0:compile [INFO] \- javax.servlet:servlet-api:jar:2.4:provided ......
這樣的話,就可以完美解決沖突了。
命令分析
這里我們對我們執(zhí)行的命令做一個簡單的說明。
mvn dependency:tree -Dverbose -Dincludes=<groupId>:<artifactId>
1、第一部分mvn dependency:tree是maven依賴的分析命令,作用是對我們的項目的依賴進行分析,并輸出項目依賴樹
2、第二部分-Dverbose的作用是添加了verbose一個環(huán)境變量,起的作用是在分析項目依賴時輸出明細(xì),這樣項目中依賴的所有3、引用都會被輸出出來,包含了所有的間接引用,會有很多很多,我們只需要我們要找的,所以就需要第三個參數(shù)了第三部分-Dincludes=<groupId>:<artifactId>的作用就是進行過濾,只包含我們想要的依賴的依賴時,排除掉其它不需要的,依賴樹的所有葉子節(jié)點就是我們的找的依賴包。其中的groupId和artifactId可以只填寫一個,為了保證準(zhǔn)確性,一般都會填兩個(填寫時不包括尖括號)。
小試牛刀
在自己的項目上,啟動時發(fā)現(xiàn)如下異常:
21-Mar-2019 15:51:33.527 信息 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
21-Mar-2019 15:52:08.905 嚴(yán)重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.server.support.WebSocketHandlerMapping#0': Cannot resolve reference to bean 'org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler#0' while setting bean property 'urlMap' with key [/websocket/**]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler#0': Cannot resolve reference to bean 'org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService#0': Cannot resolve reference to bean 'SockJsScheduler' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SockJsScheduler': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'removeOnCancelPolicy' of bean class [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler]: Bean property 'removeOnCancelPolicy' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:407)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:165)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4817)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5283)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1736)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:483)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:432)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at java.security.AccessController.doPrivileged(Native Method)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
執(zhí)行命令分析下,項目的jar包的依賴情況,只過濾并分析spring框架的jar包依賴樹情況,使用的命令如下:
mvn dependency:tree -Dverbose -Dincludes=org.springframework:
在新引入的項目jar包中,發(fā)現(xiàn)其再次引入了spring的相關(guān)包并且該spring包的層級屬于第二層級,實際已有的spring的包處在第三或者第四層級,根據(jù)就近原則,低版本的3.2.5的jar包覆蓋了高版本的jar包,導(dǎo)致出現(xiàn)找不到某變量的異常。剔除這些jar包如下配置:
<exclusion> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> </exclusion>
重新查看jar包的依賴樹:
xujiaqingdeMacBook-Pro:mos jaycee$ mvn dependency:tree -Dverbose -Dincludes=org.springframework: [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] Unrecognised tag: 'mirror' (position: START_TAG seen ...e the preferred\n | server for that repository.\n |-->\n <mirror>... @153:10) @ /software/apache-maven-3.6.0/conf/settings.xml, line 153, column 10 [WARNING] [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for fish:core-db:jar:1.0-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ fish:core-db:[unknown-version], /projects/mos/core-db/pom.xml, line 79, column 21 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] FishParent [pom] [INFO] core-db [jar] [INFO] core [war] [INFO] [INFO] --------------------------< fish:FishParent >--------------------------- [INFO] Building FishParent 1.0-SNAPSHOT [1/3] [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ FishParent --- [INFO] [INFO] ----------------------------< fish:core-db >---------------------------- [INFO] Building core-db 1.0-SNAPSHOT [2/3] [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ core-db --- [INFO] fish:core-db:jar:1.0-SNAPSHOT [INFO] \- com.hand:hap-db:jar:3.5.4-RELEASE:compile [INFO] \- com.hand:hap-core-db:jar:3.5.4-RELEASE:compile [INFO] \- org.springframework:spring-core:jar:4.3.11.RELEASE:compile [INFO] [INFO] -----------------------------< fish:core >------------------------------ [INFO] Building core 1.0-SNAPSHOT [3/3] [INFO] --------------------------------[ war ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ core --- [INFO] fish:core:war:1.0-SNAPSHOT [INFO] +- com.hand:hap-db:jar:3.5.4-RELEASE:compile [INFO] | \- com.hand:hap-core-db:jar:3.5.4-RELEASE:compile [INFO] | \- org.springframework:spring-core:jar:4.3.11.RELEASE:compile [INFO] +- com.hand:hap-pom:pom:3.5.4-RELEASE:provided [INFO] | +- com.hand:hap-core:jar:classes:3.5.4-RELEASE:provided [INFO] | | +- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework:spring-jdbc:jar:4.3.11.RELEASE:provided [INFO] | | | +- org.springframework:spring-beans:jar:4.3.11.RELEASE:provided [INFO] | | | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | \- (org.springframework:spring-tx:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework:spring-test:jar:4.3.11.RELEASE:provided [INFO] | | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework:spring-context:jar:4.3.11.RELEASE:provided [INFO] | | | +- org.springframework:spring-aop:jar:4.3.11.RELEASE:provided [INFO] | | | | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | \- org.springframework:spring-expression:jar:4.3.11.RELEASE:provided [INFO] | | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework:spring-context-support:jar:4.3.11.RELEASE:provided [INFO] | | | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-context:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework:spring-web:jar:4.3.11.RELEASE:provided [INFO] | | | +- (org.springframework:spring-aop:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-context:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework:spring-webmvc:jar:4.3.11.RELEASE:provided [INFO] | | | +- (org.springframework:spring-aop:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-context:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-expression:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | \- (org.springframework:spring-web:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- org.springframework.data:spring-data-redis:jar:1.7.0.RELEASE:provided [INFO] | | | +- org.springframework.data:spring-data-keyvalue:jar:1.1.0.RELEASE:provided [INFO] | | | | +- org.springframework.data:spring-data-commons:jar:1.12.0.RELEASE:provided [INFO] | | | | | +- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | | \- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | \- (org.springframework:spring-tx:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-tx:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- org.springframework:spring-oxm:jar:4.2.5.RELEASE:provided [INFO] | | | | +- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | \- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-aop:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-context-support:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework.security:spring-security-web:jar:4.0.4.RELEASE:provided [INFO] | | | +- org.springframework.security:spring-security-core:jar:4.0.4.RELEASE:provided [INFO] | | | | +- (org.springframework:spring-aop:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | +- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | +- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | | \- (org.springframework:spring-expression:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-expression:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-web:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework.security:spring-security-config:jar:4.0.4.RELEASE:provided [INFO] | | | +- (org.springframework:spring-aop:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework.security:spring-security-cas:jar:4.0.4.RELEASE:provided [INFO] | | | +- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-web:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework.security.oauth:spring-security-oauth2:jar:2.0.7.RELEASE:provided [INFO] | | | +- (org.springframework:spring-beans:jar:4.0.9.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-core:jar:4.0.9.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-context:jar:4.0.9.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-webmvc:jar:4.0.9.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework.security:spring-security-ldap:jar:4.0.4.RELEASE:provided [INFO] | | | +- (org.springframework:spring-beans:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-core:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-tx:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- com.ryantenney.metrics:metrics-spring:jar:3.1.3:provided [INFO] | | | \- (org.springframework:spring-context-support:jar:4.1.6.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework.amqp:spring-rabbit:jar:1.7.1.RELEASE:provided [INFO] | | | +- (org.springframework:spring-web:jar:4.3.7.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-messaging:jar:4.3.7.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- org.springframework.amqp:spring-amqp:jar:1.7.1.RELEASE:provided [INFO] | | | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-context:jar:4.3.7.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | +- org.springframework:spring-websocket:jar:4.3.11.RELEASE:provided [INFO] | | | +- (org.springframework:spring-context:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | +- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | | \- (org.springframework:spring-web:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | \- org.springframework:spring-messaging:jar:4.3.11.RELEASE:provided [INFO] | | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | +- (org.springframework:spring-context:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | +- com.hand:hap-workflow:jar:classes:3.5.4-RELEASE:provided [INFO] | | +- org.activiti:activiti-spring:jar:6.0.0:provided [INFO] | | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | | \- (org.springframework:spring-jdbc:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | \- org.activiti:activiti-rest:jar:6.0.0:provided [INFO] | | +- (org.springframework:spring-context:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | | \- (org.springframework:spring-webmvc:jar:4.2.5.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] | \- com.hand:hap-report:jar:classes:3.5.4-RELEASE:provided [INFO] | \- com.bstek.ureport:ureport2-console:jar:2.2:provided [INFO] | \- com.bstek.ureport:ureport2-core:jar:2.2:provided [INFO] | +- (org.springframework:spring-web:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | \- (org.springframework:spring-jdbc:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] \- hscs:core:jar:classes:2.2.1-SNAPSHOT:provided [INFO] \- org.springframework.kafka:spring-kafka:jar:1.3.0.RELEASE:provided [INFO] +- (org.springframework:spring-messaging:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] +- org.springframework:spring-tx:jar:4.3.11.RELEASE:provided [INFO] | +- (org.springframework:spring-beans:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] | \- (org.springframework:spring-core:jar:4.3.11.RELEASE:provided - omitted for duplicate) [INFO] \- org.springframework.retry:spring-retry:jar:1.2.0.RELEASE:provided [INFO] \- (org.springframework:spring-core:jar:4.3.3.RELEASE:provided - omitted for conflict with 4.3.11.RELEASE) [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for FishParent 1.0-SNAPSHOT: [INFO] [INFO] FishParent ......................................... SUCCESS [ 0.922 s] [INFO] core-db ............................................ SUCCESS [ 0.539 s] [INFO] core ............................................... SUCCESS [ 4.020 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.780 s [INFO] Finished at: 2019-03-21T15:38:44+08:00 [INFO] ------------------------------------------------------------------------ xujiaqingdeMacBook-Pro:mos jaycee$
實際上,對于omitted for duplicate的提示,我們可以不用去解決,只是提示了該包的重復(fù)定義。在實際情況上,更多的是根據(jù)就近原則引用了一個低版本的jar包,這樣本身高版本的Jar包包含的方法,在低版本卻沒有,導(dǎo)致項目在調(diào)用時,出現(xiàn)了“方法找不到”類似的異常信息。
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
實例解析Java的Jackson庫中的數(shù)據(jù)綁定
這篇文章主要介紹了Java的Jackson庫中的數(shù)據(jù)綁定,這里分為通常的簡單數(shù)據(jù)綁定與全數(shù)據(jù)綁定兩種情況來講,需要的朋友可以參考下2016-01-01Idea之沒有網(wǎng)絡(luò)的情況下創(chuàng)建SpringBoot項目的方法實現(xiàn)
本文主要介紹了Idea之沒有網(wǎng)絡(luò)的情況下創(chuàng)建SpringBoot項目的方法實現(xiàn),文中通過圖文介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-09-09Windows系統(tǒng)編寫bat腳本啟動、停止及重啟Java服務(wù)jar包
在bat文件中我們將編寫一些代碼來運行Java jar文件,下面這篇文章主要給大家介紹了關(guān)于Windows系統(tǒng)編寫bat腳本啟動、停止及重啟Java服務(wù)jar包的相關(guān)資料,需要的朋友可以參考下2023-12-12