第一步:简单构建springboot

74 阅读1分钟

1. pom文件


<parent>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-parent</artifactId>

    <version>2.3.5.RELEASE</version>

</parent>

<dependencies>

<!-- web开发启动依赖 -->

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-web</artifactId>

    </dependency>

</dependencies>

2. controller代码


@RestController

public class HelloController {

    @RequestMapping("/hello")

    public String hello(){

        return "Hello Spring Boot ! ";

    }

}

3. 启动类


/**

* 启动类

*/

@SpringBootApplication

public class LyshopApplication {

    public static void main(String[] args) {

        SpringApplication.run(LyshopApplication.class);

    }

}

启动项目,浏览器访问 http://localhost:8080/hello