0
点赞
收藏
分享

微信扫一扫

SpringBoot简介及快速搭建

SpringBoot简介及快速搭建

1、SpringBoot简介

优点

2、为什么要用SpringBoot

3、SpringBoot的hello world

3.1、IDEA运行SpringBoot的HelloWorld

<!-- 提供了springboot统一的依赖管理和插件管理 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.2</version>
</parent>


<dependencies>
    <!-- 默认提供SpringBoot 框架需要开发web应用需要的包 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.5.2</version>
    </dependency>

</dependencies>
package cool.ale.controller;

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

/**
 * @author dujlc
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping("/world")
    public String SayHi(){
        return "Hello World";
    }
}
package cool.ale.appStart;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author dujlc
 */
@SpringBootApplication(scanBasePackages="cool.ale.controller")
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}

3.2、cmd窗口运行SpringBoot的HelloWorld

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

<!-- 在打包的时候我们可以让他找到 springBoot启动的主类 -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

在这里插入图片描述

举报

相关推荐

0 条评论