Я работаю с проектом Maven, и у меня есть два проекта: ProjectA
и ProjectB
. Моя ProjectA
- это библиотека maven, pom которой выглядит так:
ProjectA POM:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.texture.partial</groupId>
<artifactId>PartialPlatform</artifactId>
<version>2.1.5-RELEASE</version>
</parent>
<groupId>com.texture.transform.golden</groupId>
<artifactId>SampleClientProjectA</artifactId>
<version>1.0.4</version>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.texture.partial.core</groupId>
<artifactId>PartialKernel</artifactId>
</dependency>
<dependency>
<groupId>com.texture.webres</groupId>
<artifactId>WebResPartial</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>TextureServer</artifactId>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>Kernel</artifactId>
</dependency>
<dependency>
<groupId>com.texture.v3jars.Houston</groupId>
<artifactId>KerlDEL</artifactId>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>pKerl</artifactId>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>pKerlCore</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.cglib</artifactId>
</dependency>
<dependency>
<groupId>com.texture.partial.core</groupId>
<artifactId>ConfigWeb</artifactId>
</dependency>
<dependency>
<groupId>com.texture.partial.core</groupId>
<artifactId>PartialWeb</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<instrumentation>
<excludes>
<exclude>**/test/**/*.class</exclude>
</excludes>
</instrumentation>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</build>
</project>
В моем выше pom PartialKernel
приносит более старую версию различных зависимостей Spring Framework, таких как spring-core
, spring-web
. Это версия 3.2.8.RELEASE
, и я хочу использовать последнюю версию этих двух весенних фреймворков, а именно 4.1.6.RELEASE
.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
Мне нужно использовать последнюю версию, так как некоторые классы есть только в последней версии. Поэтому я добавил новую версию этих двух библиотек в свой pom.xml, как и в свой ProjectA. У меня есть основной код static void, который будет тестировать функциональность ProjectA
и отлично работает без каких-либо проблем.
Теперь у меня есть ProjectB
, который также имеет тот же выше pom, что и без последней версии весенней зависимости. В моем ProjectB
pom у меня есть зависимость ProjectA
и тот же код, который будет проверять функциональность ProjectA
, но всякий раз, когда я запускаю тот же класс в ProjectB
, я всегда получаю эту ошибку.
Exception in thread "main" java.lang.NoClassDefFoundError: org.springframework.util.concurrent.ListenableFutureCallback
Caused by: java.lang.ClassNotFoundException: org.springframework.util.concurrent.ListenableFutureCallback
Весь последний код, связанный с Spring, который я использую, находится в ProjectA
, в котором у меня уже есть последняя версия Spring. Образец тестового кода, который у меня есть, предназначен только для вызова ProjectA
классов, вот и все, чтобы протестировать его.
ProjectB POM:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.texture.partial</groupId>
<artifactId>PartialPlatform</artifactId>
<version>2.1.5-RELEASE</version>
</parent>
<groupId>com.texture.transform.golden</groupId>
<artifactId>SampleTestClientProjectB</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.texture.partial.core</groupId>
<artifactId>PartialKernel</artifactId>
</dependency>
<dependency>
<groupId>com.texture.webres</groupId>
<artifactId>WebResPartial</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>TextureServer</artifactId>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>Kernel</artifactId>
</dependency>
<dependency>
<groupId>com.texture.v3jars.Houston</groupId>
<artifactId>KerlDEL</artifactId>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>pKerl</artifactId>
</dependency>
<dependency>
<groupId>com.texture.kernel</groupId>
<artifactId>pKerlCore</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.cglib</artifactId>
</dependency>
<dependency>
<groupId>com.texture.partial.core</groupId>
<artifactId>ConfigWeb</artifactId>
</dependency>
<dependency>
<groupId>com.texture.partial.core</groupId>
<artifactId>PartialWeb</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.texture.transform.golden</groupId>
<artifactId>SampleClientProjectA</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<instrumentation>
<excludes>
<exclude>**/test/**/*.class</exclude>
</excludes>
</instrumentation>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</build>
</project>
Но когда я добавляю последнюю версию зависимости Spring в свой ProjectB, мой тестовый код начинает работать нормально. А вот этого я не хочу. Есть ли способ, чтобы мой ProjectB начал автоматически использовать любую зависимость, которую я использую в ProjectA? Если они хотят изменить его, они могут переопределить его в своем коде в ProjectB.