IDEA installs, configures Spring boot and creates a project (mac version)

As long as your java and maven versions are correct and the configuration is completed in idea, you can easily develop SpringBoot applications in idea!

For more information, please go to the official documentation (Chinese version) Introduction · Spring Boot Chinese documentation http://felord.cn/_doc/_springboot/2.1.5.RELEASE/_book/


step

1. Check the installation of Java. Note that Java SDK 1.6 or higher is required.

java -version


2. Select Maven to install SpringBoot (you can also use Gradle, etc.)

Please first ensure that you have installed Maven and configured it in IDEA.

mvn -version


3. Open IDEA and create a new project, as shown below

 After the creation is completed, because it is the first time to create it, you have to wait for a while because it is still loading some plug-ins. At this time, the demo on the right may report an error. Wait patiently until the loading is completed, click demo, and then click run.

 After running:

Enter http://localhost:8080/ in the browser 

The appearance of this page indicates that the springboot environment is configured successfully !


4. Add code to make the page display something

Create a new class named HelloController and enter the code.

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String hello() {
        return "Hello Spring Boot~";
    }

}

 Restart the project and enter the address in the browser: http://localhost:8080/hello


overover! It’s not easy to make, please like and collect it~

Guess you like

Origin blog.csdn.net/weixin_46019681/article/details/124895984