2010-10-10 9 views
7

Mam wielomodułowy projekt Maven i chcę, aby projekty podrzędne dziedziczyły wersje dla zależności od stron trzecich, które określiłem w projekcie nadrzędnym. Jest tak, że nie muszę powtarzać numerów wersji wszędzie. To nie działa, choć i kiedy wychodzę z numerem wersji na dzieci pojawia się błąd:W jaki sposób mogę sprawić, aby moje projekty podrzędne dziedziczyły wersje zależne od super projektu w ramach wielomodułowego projektu Maven?

dependencies.dependency.version is missing 

Co muszę zmienić, aby dostać tę pracę?

+0

Należy pokazać odpowiednią część plików pom.xml –

Odpowiedz

11

The <dependencyManagement> section of the parent POM jest przeznaczona do tego celu:

dependencyManagement : is used by POMs to help manage dependency information across all of its children. If the my-parent project uses dependencyManagement to define a dependency on junit:junit:4.0 , then POMs inheriting from this one can set their dependency giving the groupId=junit and artifactId=junit only, then Maven will fill in the version set by the parent. The benefits of this method are obvious. Dependency details can be set in one central location, which will propagate to all inheriting POMs. In addition, the version and scope of artifacts which are incorporated from transitive dependencies may also be controlled by specifying them in a dependency management section.

+0

nie wiesz, co PO zrobiła dokładnie ale to jest prawidłowa odpowiedź :) –

0

Co zrobić, bo to jest zdefiniowanie wersje zależnościami, że muszę powtórzyć jako własność w projekcie dominującej . Więc:

<properties> 
    ... 
    <guice.version>2.0</guice.version> 
</properties> 

A potem:

<dependency> 
    <groupId>com.google.inject</groupId> 
    <artifactId>guice</artifactId> 
    <version>${guice.version}</version> 
</dependency> 

Niezupełnie co prosisz może, ale to oznacza, że ​​trzeba tylko zmienić wersję w jednym miejscu.

Powiązane problemy