As a java developer who transferred from eclipse to idea, he suffered a lot in the process of adapting to idea, including the most basic idea directory structure, running and debugging, code completion, editor style and so on. At the beginning, he didn’t adapt at all.
So far, I have been using idea for three months. Although I still focus on sts4 of eclipse series, I am basically familiar with the use of idea. In addition to the recent integration of microservices, it is necessary to integrate multiple completed microservices into a separate Maven project as Maven modules.
At this time, the benefits of idea are reflected. The structure of the idea project itself is that the project contains modules, so it is easier for developers who are used to the idea style to create Maven projects containing multiple spring boot projects.
First, let’s take a look at the comparison between the directory structure of the idea project and that of eclipse (STS):
For what to do at this timeMaven project for creating parent-child structureGenerally speaking, according to the understanding of eclipse hierarchy:
workspace -> maven peoject -> maven module，
But under idea:
maven project -> maven module
I think there is no difference between the two ides in creating parent-child Maven projects.
Talk less and get down to business.
Create Maven parent project:
- Create idea spring initializr,
File – > new, select spring initializr to ensure that the SDK environment is correct. Click next
- Note: at this time, select Maven POM in type. The advantage of this is to prevent the generation of paths we don’t need, such as Src. It’s OK not to select POM, but you need to manually delete SRC and other paths after creation.
- Select the dependency of the parent Maven project – note that the dependency selected here is for all child modules
- The last step is to confirm the information to finish – pay attention to the interface in this step
project LocationAnd lower half
More SettingThe path of the part should be correct. Basically, there will be no problem, but because it is an automatically set path, you’d better confirm it and finally finish.
After the creation is successful, the lower right corner of the idea will prompt whether to automatically add Maven dependencies. Click
enable auto importAll right
At this point, a maven parent project is created. Open the project tab, or press windows
Alt+1, MAC down
Command+1You can see the project structure of the newly created project.
You can see that only one POM has been generated:
This POM is the POM of a normal spring boot project
proposal: subprojects are created in Maven format instead of the spring boot project.
- Parent project mail, create module
- Select Maven in the left column and click next
- Make sure that the parent item and path are correct
- Click finish
- The directory structure is as follows:
- The parent tag is defined in the POM of the subproject
- The module tag of the child project is defined in the POM of the parent project:
At this point, we can write code happily.