IDEA Tool Pit Avoidance Guide (11): After git imports SpringBoot | does not recognize dependencies | a large number of popular | cannot start

I. Introduction

In IDEA 2019, after using the Git tool to import the SpringBoot project, a large number of java class dependency packages became popular, SpringBoot could not be started, and the startup class could not be automatically recognized.

Tip: If the project just pulled has only .git and .idea files, no src or java directory , click to enter !

2. Error description

2.1 The startup icon is gray and cannot be started

2.2 The startup entry class is not recognized, and there is no startup green icon

2.3 When configuring the startup entry, an error is reported, it cannot be configured, and the OK button cannot be clicked

Click in the upper right corner of IDEA, click Add Configuration in turn, click Templates in the pop-up window , and find the SpringBoot option in the drop-down list

 

2.4 java, resource, test files are not recognized as different resource file types

2.5 After various magical operations, a large number of imported packages became popular and were not recognized

 Can't bear to look directly (skip~~) 

3. Results display

Then click Add Configuration to look at the configuration, and it is normal.

 

4. Solutions

Warm up

1. Configure Maven and Maven's setting.xml configuration file ( do not use IDEA's default )

Shortcut key: ctrl+Alt+s, open the settings, modify the installation location of maven

For more maven configuration, if you need help, click the link below

Click to enter: Maven environment configuration , Maven configuration in IDEA ( refer to chapter 1, 1.2 )

2. In the project directory, right-click pom.xml, Add as Maven Project

After the operation, be sure to Reimport first

3. Configure various JDKs for the project itself

Shortcut key: Ctrl+Alt+Shift+s

Tip: Not limited to the following two places, the JDK configuration is relatively simple, make up your own brain


---------------¥¥¥¥¥¥¥¥¥如果热身动作不能解决,继续向下看¥¥¥¥¥¥---------- -------


Be sure to know that the above warm-up actions have been dealt with , and then read the following plan, otherwise the following plan may not be suitable for you ! ! !

Option 1 ( recommended )

done the above warm-up

Ctrl+Alt+Shift+S , open the Project Structure project structure, and you will see the following directory structure without accident:

The root of the problem is here, and one set needs to be deleted. The analysis is as follows:

Click on the two modules respectively, and you can see that there is a set of the same java code under the two modules

 

At this time, one set needs to be deleted . Here I delete the set with the name of the project to be deleted ( essentially, it does not belong to the module, but is the leadership of the module ). When removing, there will be a prompt, just confirm it directly.

 Finally, click the OK button at the bottom of the popup

Special reminder: If your resource file icon is not specially marked, follow the steps below to mark it yourself.

 Steps:

1) First click the java folder below , and then click the source code icon in the middle;

2) Click the resources below again , and then click the Resources icon in the middle ;

3) Finally, click the test folder below, and then click the test icon in the middle;

4) Click the "OK" button on this window.

So far, under normal circumstances, the problem is completely solved when the steps are carried out here, and the effect is as follows:

Select the startup module, without this operation, it will prompt that the startup module cannot be found when starting.

As shown in the figure below, check the modules that need to be started

At the same time, check the small tick below

Expansion 1: If you encounter the following error when starting the project, the solution steps are as follows

 

IntelliJ IDEA Debug时报错
Cannot start compilation: the output path is not specified for module “NewFrameWork2023".
Specify the output path in the Project Structure dialog. 

 If you see this error, the solution is as follows

Ctrl+Alt+Shift+S , open the Project Structure project structure, select the Module module, and click " Use the module to compile the output path "

English version: File->Project structure->Modules->Select "Inherit project compile path" and click the OK button.

Expansion 2: If you encounter the following error when starting the project, the solution steps are as follows

The cause of the problem is that you have changed your local JDK, such as JDK1.8, you installed a newer version of JDK for some operations, and modified the environment variable of JDK to a higher version, which caused the problem.

In order to run this project, you need to change the JDK environment variable to JDK1.8, as follows:

Java JDK环境变量配置
JAVA_HOME
D:\Program Files\Java\jdk1.8.0

CLASSPATH
.;%JAVA_HOME%\bin;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%TOMCAT_HOME%\lib\servlet-api.jar;

path
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin

JDK高版本配置(只需要配置两项)
JAVA_HOME
D:\Program Files\Java\jdk-20\jdk20.0.0
path
%JAVA_HOME%\bin

Note: If you configure an old version of JDK, use the java -version command in the CMD window to check the jdk version. If it does not take effect, you need to move the environment variable configured in the path to the top, and then restart the computer. 

Option 2 (not recommended)

Close IDEA and enter the workspace, delete the .idea file, and reopen IDEA. This magical operation does not work every time. Even after it takes effect, the effect is not ideal. Some files that you don’t want to see will appear, and the directory structure is also a bit messy.

The extra stuff looks very inelegant, and this solution is not recommended

third solution

File-->Invalidate Caches / Restart, wait for God to operate

Slightly slightly, if the above method does not solve your problem, leave a message and help solve it!

5. Acknowledgments

Two modules in a project cannot share the same content root - Stack Overflow

6. Summary

This article describes the problem that in IDEA, after pulling the SpringBoot project through the git tool, it cannot be started and cannot be recognized as a SpringBoot project. It focuses on reproducing the problem and the solution steps, and briefly introduces other divine solutions.

7. Epilogue

Being able to see this shows that this article is really good, what are you waiting for, hurry up to like, leave a message, and comment, haha!

8. Appendix

1.  IDEA Tool Pit Avoidance Guide (1): After a new project is imported, Class and package cannot be created

2.  Guide to Avoid Pitfalls for IDEA Tools (2): After importing a Maven project, the Maven sidebar is not displayed

3.  IDEA Tool Pit Avoidance Guide (3): When the project is running, it prompts that the JDK version is too low and needs to be replaced

4.  IDEA Tool Pit Avoidance Guide (4): How to hide unnecessary suffix files (optimization)

5. IDEA Tool Pit Avoidance Guide (5): How to Uniformly Encode UTF-8 (Optimization)

6. Guide to Avoid Pitfalls for IDEA Tools (10): After git pulls the java project, there are only .git and .idea files in the pulled project directory, and there is no src or java directory

7. IDEA Tool Pit Avoidance Guide (11): After git imports SpringBoot | does not recognize dependencies | a large number of popular | cannot start

Guess you like

Origin blog.csdn.net/xp871038951/article/details/129972430