Spring Notes 2-HelloSpring, the first Spring project, to solve the problem of template java not highlighting

After the first chapter we have configured Spring's related environment and imported Maven dependencies, we started to create our first spring project.
If you have not configured the maven project, please go to
Spring Note 1-Spring Installation Configuration and First Understanding

The maven after fully importing the dependency package is as follows.
Insert picture description here
In order to avoid the troublesome operation of creating a maven project every time you write spring code, we use templates to develop.
We delete the src under the package in the newly created project, and press Follow the steps below

1. Right-click the project name, click new------->click module

Insert picture description here

2. Let's call it HelloSpring, and we will operate step by step as shown in the figure below

Insert picture description here
Insert picture description here

3. Finally, we see the pom.xml configuration file of the total maven project. Note that it is the pom.xml of the project, not the pom.xml file of the template you created. We found that it has an additional module and module tag, which means we are in The import of this maven project is successful, and if you delete the related template, don't forget to delete the corresponding module tag and content! ! !

Insert picture description here

4. We expand the template we created and find that both java files are highlighted

Insert picture description here

but! ! ! ! , Some friends, these two java are not highlighted, that is, they are grayed out like other files. At this time, it is found that the new class project is not available. Then we continue to solve the problem according to the following methods

Click file in the menu bar, then click project structure (shortcut key is ctrl+alt+shirt+S)

Insert picture description here

We find Source Folder and Test Source Folder respectively (whisper bb: If you don’t have these two files, you can create them, but basically there are)

Insert picture description here

In steps 4 and 5, close and save, and java will be highlighted, and you can write code happily right away.

As for how to write the code, we will go into details in the next section (this section also has a lot of stuff)

Guess you like

Origin blog.csdn.net/YSJ367635984/article/details/113103689