Skip to content

How to add module dependency to other module in Java Project Intellij

I havr two modules in this project (JavaRESTfulEngine and Models). Java RESTful engine depends on models. enter image description here

I added the dependency here: enter image description here

But in my JavaRESTfulEngine project I still get reference errors. For example, the Document class is in the Models module, but I cannot find it when trying to import the class in JavaRESTful module: enter image description here The goal is that Models is compiled down to a jar and used in the JavaRESTful project during runtime. Does anything stand out as wrong in my setup? EDIT I changed the scope from compile to provided and it still doesnt work.


You don’t have to change the scope of the jars. If you want to use the libraries of the Models module in the JavaRESTfulEngine module, you just have to make sure that each jar you want to reuse from Models has the “Export” check box activated and that the reference to the Models folder is inside the JavaRESTfulEngine module (just like I see you have it in the second photo)