SpringBoot 快速体验

Posted on   弯弓射雕的男人  阅读(4)  评论(1编辑  收藏  举报

 1.创建项目

maven 项目

<!--    所有springboot项目都必须继承自 spring-boot-starter-parent -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.5</version>
    </parent>

2.导入场景

场景启动器

    <dependencies>
<!--        web开发的场景启动器 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
3.主程序
@SpringBootApplication //这是一个SpringBoot应用
public class MainApplication {

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

4. 业务

复制代码
@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello(){

        return "Hello,Spring Boot 3!";
    }

}
复制代码

 

之后就可以启动了

 接下来  感受一下  springboot3 

打包成jar文件 

 也就是打开文件所在位置

 在文件所在位置可以直接运行jar包

 

 如果想要更改配置 

在文件相同路径下增加配置文件 application.properties

 

在里面写你的配置 然后保存 在次运行

 

 

点击右上角即可分享
微信分享提示