How to create a spring boot

Nowadays, springboot is getting more and more popular, and more and more companies choose to use springboot as the development framework of the project. Its design purpose is to simplify the construction and development process of spring projects, omitting the cumbersome configuration of traditional spring and springmvc projects, so that Developers get started quickly.

The following is a detailed description of how to use idea to create our first springboot project:

First open the main interface of idea and select Create New Project

Insert picture description here
On the page that pops up, we select Spring Initializr on the left, the jdk version chooses the version installed by ourselves, I choose 1.8 here, and the URL chooses the default.

Special note: Since the springboot version is 2.0.3, the jdk version should be 1.8 and above, otherwise it will not be supported. The Default URL selected here can be loaded only when there is a network. Just go directly to Next.
Insert picture description here
Next page: Enter the organization name in the Group column, Artifact is the project name. Other choices are just fine by default. Just
pay attention to the version number here. We choose the latest 2.0.3 by default. Since we need to build a web project to verify whether the project is successfully built by accessing the Controller, we add a web package here. Then Next——>Select the initial path of the project——>Finish to complete the creation.
Insert picture description here
Insert picture description here
A box indicating that the project path does not exist may pop up, asking whether to create it, and click OK. If you haven't created a springboot project before, the first initialization of the project may be slow. Just wait patiently. It depends on the computer configuration and network speed.

The following is the initialization structure of the project. By default, a startup class is created for us. The package path is the Group+Artifact we just filled in.
Insert picture description here

Pay attention to the version of springboot in the POM, change the version to 2.1.3 if it cannot run, and just import it.

Click the triangle on the left of the main method and select the first run to start the project. After the startup is complete, you can see the spring logo, you can see 8080 (http) with context path", which means
Insert picture description here
that we can access it on the webpage after it has been successfully started. Enter localhost:8080 in the webpage address bar and you can see anything after completion. No, because we haven't written anything yet.
Insert picture description here
Let's create a HelloController class and enter the code. Remember to add the annotations in the figure.
Insert picture description here
Run it, and enter localhost:8080/hello on the web page
Insert picture description here
so that it runs successfully.

Guess you like

Origin blog.csdn.net/weixin_44941105/article/details/95381389