Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
852 views
in Technique[技术] by (71.8m points)

maven share dependencies among different modules

I have a project with 5 modules.

2 of the modules have a dependency of hibernate. they are siblings and not parent child hence one cannot inherit another one's dependencies

is there a way to specify hibernate related dependency in parent and make the 2 modules inherit it and the other 3 modules wont inherit it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes there is. Create a parent pom.xml with the shared hibernate dependency and add a parent declaration to your 2 modules:

<parent>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
    <relativePath>...path-to-parent.../pom.xml</relativePath>
</parent>

Declare the hibernate dependency in the dependencies section of your parent pom:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>${hibernate.version}</version>
    </dependency>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...