SpringBoot 快速体验

Posted on   弯弓射雕的男人  阅读(5)  评论(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

 

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

 

 

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示