In actual work, we often encounter this situation. We create a common project (Maven project) as a public project. There are many tool classes in common that can be called by multiple other projects.
For example, the common and service are separated into separate Maven projects for use by other projects, and are referenced by other projects through jars.
Now web projects need to reference common and service. If IDEA opens common, service, and web projects separately, then when debugging web projects, you will encounter difficulties: the code in common and service referenced by web is packaged into jars and cannot be debugged. Unless the source code is installed to the local repository when the common and service is installed, it is inconvenient. Each time the common and service update requires the maven install operation, the code referenced in the web will be updated.
1. Eclipse solution
Eclipse has the concept of WorkSpace. Put common, service, and web into one WorkSpace. Eclipse will open all projects in WorkSpace. Eclipse will automatically find dependencies. Click common code in the web and will jump directly to the corresponding source code in common. During debugging, it can also be adjusted to common and step-by-step debugging, which is very convenient.
So can IntelliJ IDEA also implement WorkSpace function? Of course, IntelliJ IDEA is very powerful, and this function must be available!
2. IntelliJ IDEA Solution
2.1 First, download the common, service, and web projects from SVN to a local directory, for example, to a folder named WorkSpace:
2.2 Open the IntelliJ IDEA compiler, click the menu File->Open..., and select the WorkSpace directory just now:
Click OK to open the WorkSpace directory. The interface after opening is as follows:
2.3 After opening it, it is found that IDEA does not automatically recognize the Maven project. At this time, you need to manually add the project's pom.xml file in the Maven Projects column on the right side of IDEA, so that IDEA can recognize it:
Press and hold Ctrl to select the pom.xml file and click the OK button.
2.4 Okay, here IDEA can already identify the dependencies between each Maven project.
Summarize
The above is the graphic tutorial for IntelliJ IDEA that I introduced to you about opening multiple projects like Eclipse. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!