Create a springboot project from the https://start.spring.io website in IDEA

content

1. Open the website

2. Import Demo into IDEA

3. Write the Controller class

4. Start the test


1. Open the website

1> Website link: https://start.spring.io/    Select the version of Project, Language, Springboot

2> Enter the Group, project name, etc., and select the required packaging method and Java version

 3> At the top right Dependencies, click ADD........ Add the required dependencies

This demo only adds a spring web dependency

4> Click GENERATE to generate the code package, download it locally and unzip it

2. Import Demo into IDEA

1> File------>New------>Project From Existing Sources------>Select pom.xml in the project------>OK

Just wait for it to load (be patient, it will take a certain amount of time)

 

2> The loaded directory structure is as follows

3> File------>settings Check the configuration of Maven, which can be used locally. If you modify it, please refresh the maven and load the dependencies.

3. Write the Controller class

The startup class has been configured by default

We just need to write the test class.

package com.example.ldd_demo;

/**
 * @author 蓝多多的小仓库
 * @title: HelloController
 * @projectName ldd_demo
 * @description: ldd_annotation
 * @date 2022/1/14 16:24
 */

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

@RestController
public class HelloController {
  @GetMapping("/hello")
  public  String hello(){
    return "hello ldd";
  }
}

4. Start the test

Type in your browser: http://localhost:8080/hello

        So far, we have completed a simple case of creating a springboot project from the https://start.spring.io website. Thanks Mingge @programmingworldmingshiyin  for his technical guidance!

Guess you like

Origin blog.csdn.net/qq_43554335/article/details/122496472