Add a module dependency in Maven

the_critic

I have got two Maven projects. One of them has to be dependent on the other. I use IntelliJ and I have tried to right click on project1 > Open Module Settings, and in the dependencies tab I clicked on the + symbol to add a directory or jar dependency. So far so good, when I try to import packages from the dependency it autocompletes it for me, however the compilation throws errors, saying that there are no such packages. What am I doing wrong ?

JB Nizet

There is no notion of project in Maven.

You have a Maven project B. You chose its groupId (com.mycompany, for example), its artifactId (B, for example), and its version (1.0-SNAPSHOT, for example). You run mvn install on this project. This generates a B-1.0-SNAPSHOT.jar file and stores it in your local Maven repository, with its pom.

Now you want to use B-1.0-SNAPSHOT.jar in another Maven project A. For A, B is a library, just like any other library you use (log4J, Spring, Hibernate, Guava, whatever). So you add a dependency to it in the pom of A, just like you do for any other library:

<dependencies>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>B</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <!-- other dependencies: log4J, Spring, Hibernate, Guava, whatever -->
</dependencies>

Read the awful documentation for more details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Add a dependency to a maven module without sources

From Dev

Add ngAnimate Dependency on module

From Java

How to add a non-modular Maven dependency to the module path as an automatic module?

From Dev

IntelliJ - Replace dependency to a module with dependency to the Maven artefact

From Dev

maven multi module dependency version

From Dev

maven multi module dependency version

From Dev

Maven multiple module dependency build

From Dev

how to add jar dependency in maven?

From Dev

With maven, add a dependency to pom and download it?

From Dev

Dynamically add a new maven dependency?

From Dev

IntelliJ gradle add module dependency

From Dev

IntelliJ gradle add module dependency

From Dev

Maven module dependency source instead of repository jars

From Dev

Maven profile not seeing dependency in child module

From Dev

How to install the impl module for a api dependency in maven

From Dev

Copy war dependency mentioned in maven jar module

From Dev

Nar dependency in multi-module maven project

From Dev

Maven multi-module dependency resolution

From Dev

Maven Multi-module dependency package not found

From Dev

Error resolving dependency for maven multi module project

From Dev

Maven profile not seeing dependency in child module

From Dev

Maven project as a dependency module of gradle project

From Java

Maven cannot resolve dependency for module in same multi-module project

From Dev

can't add maven dependency - apache poi

From Dev

How can I add JDT as a Maven dependency?

From Dev

Best way to add local dependency to Maven project

From Dev

Add maven dependency to Android Studio gradle

From Dev

What happens when I add a Maven dependency?

From Dev

How to add a Maven project as a Gradle dependency?

Related Related

  1. 1

    Add a dependency to a maven module without sources

  2. 2

    Add ngAnimate Dependency on module

  3. 3

    How to add a non-modular Maven dependency to the module path as an automatic module?

  4. 4

    IntelliJ - Replace dependency to a module with dependency to the Maven artefact

  5. 5

    maven multi module dependency version

  6. 6

    maven multi module dependency version

  7. 7

    Maven multiple module dependency build

  8. 8

    how to add jar dependency in maven?

  9. 9

    With maven, add a dependency to pom and download it?

  10. 10

    Dynamically add a new maven dependency?

  11. 11

    IntelliJ gradle add module dependency

  12. 12

    IntelliJ gradle add module dependency

  13. 13

    Maven module dependency source instead of repository jars

  14. 14

    Maven profile not seeing dependency in child module

  15. 15

    How to install the impl module for a api dependency in maven

  16. 16

    Copy war dependency mentioned in maven jar module

  17. 17

    Nar dependency in multi-module maven project

  18. 18

    Maven multi-module dependency resolution

  19. 19

    Maven Multi-module dependency package not found

  20. 20

    Error resolving dependency for maven multi module project

  21. 21

    Maven profile not seeing dependency in child module

  22. 22

    Maven project as a dependency module of gradle project

  23. 23

    Maven cannot resolve dependency for module in same multi-module project

  24. 24

    can't add maven dependency - apache poi

  25. 25

    How can I add JDT as a Maven dependency?

  26. 26

    Best way to add local dependency to Maven project

  27. 27

    Add maven dependency to Android Studio gradle

  28. 28

    What happens when I add a Maven dependency?

  29. 29

    How to add a Maven project as a Gradle dependency?

HotTag

Archive