pom的配置里面允許用<exclusion>來排除一些不需要同時下載的依賴jar 。
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>2.5.6</version> <exclusions> <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-core</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </exclusion> </exclusions> </dependency>
maven排除依賴jar處理,但是這樣在某些時候會造成一些不可預測的異常。比如上面的程序,根據maven介紹,上面的結構會排除對spring-beans,spring-context,spring-core,spring-web 2.5.6版本的依賴.
