Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Can't access classes from one module in other module

I have set up my project as Empty Template and added Spring boot project as a module and another module ecomm-models (This contains purely java classes).

I cannot access classes in ecomm-models inside Spring boot project even though I added it as a dependency in Spring-boot project.

Both these projects are under parent-module as in picture.

Any advise that would be great!

enter image description here

enter image description here

After adding models dependcy in Spring boot. Spring-Boot pom.xml looks like this in pic.

enter image description here

like image 953
vyeluri5 Avatar asked Jun 07 '18 09:06

vyeluri5


People also ask

How do I import a class from another module in IntelliJ?

Import an existing moduleFrom the main menu, select File | New | Module from Existing Sources. In the dialog that opens, specify the path the . iml file of the module that you want to import, and click Open. By doing so, you are attaching another module to the project without physically moving any files.

How do I use classes from another project in IntelliJ?

Right click on project and select open module settings. Go to dependencies tab. click plus sign and add the module you want to use.

How do I see all classes in IntelliJ?

By default, IntelliJ IDEA shows all classes, methods, and other elements of the current file. To toggle the elements you want to show, click the corresponding buttons on the Structure tool window toolbar. to show class fields. to have protected class members shown in the tree.


1 Answers

The missing part in this project is to add packages inside the ecomm-models project/module.

The path should look like

ecomm-models > src > main > java > {package name} > person.java

Since I didn't create a package, it couldn't find the reference.

like image 194
vyeluri5 Avatar answered Oct 09 '22 18:10

vyeluri5