Day 7

1月17日,继续看了一些SpringBoot视频,
SpringBoot的实现步骤

SpringBoot项目的起步依赖

<!-- springboot工程需要继承的父工程 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
</parent>
<dependencies>
<!-- web开发的起步依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

引导类,一般Application结尾

/**
 * 引导类。 SpringBoot项目的入口
 */
@SpringBootApplication
public class HelloApplication {

    public static void main(String[] args) {
        SpringApplication.run(HelloApplication.class,args);
    }
}

Main方法

@RestController
public class HelloController {

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

运行后自动启动tomcat,浏览器搜索localhost:8080/hello即可(hello为Main方法中 @RequestMapping("/hello")的内容)

posted @ 2025-01-18 21:00  阿伟·  阅读(19)  评论(0)    收藏  举报