springboot

  1. http://springboot.javaboy.org/2019/0412/springboot-init
    maven 创建springboot2
    image

创建完成后,在 pom.xml 文件中,添加如下依赖:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.4.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

添加成功后,再在 java 目录下创建包,包中创建一个名为 App 的启动类,如下:

@EnableAutoConfiguration
@RestController
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }
}

@EnableAutoConfiguration 注解表示开启自动化配置。

然后执行这里的 main 方法就可以启动一个 Spring Boot 工程了。

原文地址:https://www.cnblogs.com/jigr/p/15492238.html