All-round analysis to solve the problem that the old name is still displayed after modifying the maven project module name in the idea

All-round solution to the problem that the old name is still displayed after modifying the maven project name in the idea

sample question

insert image description here

problematic operating procedures

1. Generally, in the project idea tool, right-click Refactor->Rname to modify the module name.
insert image description here
2. Choose to modify the directory or the module name. I usually choose to modify the module name and directory name
insert image description here

3. After modifying the module name and directory name, you will refresh maven. Here you will be prompted to reload the project and delete the kerwin-ability-change module. At the beginning, I didn’t see it clearly and thought it was to reload the kerwin-ability-change module. I chose yes
insert image description here
4. Here you can see that this project is not recognized by maven, because the module of the parent pom file has not been changed or the old module name is used
insert image description here
5. After changing the module name in the parent pom to the current module name, refresh maven We will see that the pom file of this module has become gray
insert image description here
6. To restore this module to normal, you need to enter the maven configuration of Settings and cancel the ignore, because it was ignored in the third step and
insert image description here
the module appeared after confirmation The problem that the name and the directory name do not correspond
insert image description here

Cause of the problem

  • The reason for this problem is that in the third step, maven was refreshed without modifying the module name in the parent pom in advance and the kerwin-ability-change module was ignored. After the parent pom was modified and the kerwin-ability-change module was ignored later The module name of the directory on the left side of the idea directly refers to the old module name. We can observe that there are always old module names in the Project Structure that will not be deleted. Here, you can directly delete the corresponding module in the Project Structure and refresh maven to solve the problem.
  • If you change the module name in the parent pom file to the directory name in advance before refreshing maven in the third step, this problem will not occur. Modifying the module name in the idea tool will not modify the module name in the pom file. You must manually modify it

insert image description here

problem solving

1. First check whether the modules->module in the parent pom are correct, and then check whether the artifactId of the current module is correct. If it is inconsistent, change it to the directory name PS: (This artifactId will not affect the display of the project directory module name on the left of the idea, and will
affect The module name in the maven management on the right side of the idea)
2. Directly right-click Refactor->Rname and choose to modify only the module name
insert image description here

insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44606481/article/details/129317767