springboot快速入门

springboot快速入门,第1张

通过Spring Boot,可以轻松地创建独立的,基于生产级别的基于Spring的应用程序,您可以“运行”它们。
特征
创建独立的Spring应用程序

直接嵌入Tomcat,Jetty或Undertow(无需部署WAR文件)

提供自以为是的“入门”依赖项,以简化您的构建配置

尽可能自动配置Spring和3rd Party库

提供可用于生产的功能,例如指标,运行状况检查和外部化配置

完全没有代码生成,也不需要XML配置

快速入门
1.创建maven工程
2.添加springboot的起步依赖
springboot要求,项目必须继承springboot起步依赖spring-boot-starter-parent

<parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.6.6version>
    parent>

3.编写springboot引导类(入口)

@SpringBootApplication
public class MySpringBootApplication {
    public static void main(String[] args) {
        SpringApplication.run(MySpringBootApplication.class);

    }
}

4.编写controller
springboot要集成springmvc进行controller开发,所以项目要导入web的启动依赖

<dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>
    dependencies>
@Controller
public class QuickController {
    @RequestMapping("/quick")
    @ResponseBody
    public String quick(){
        return "hello spring";
    }
}

5.springboot工程的热部署

   <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
        dependency>

6.springboot集成mybatis

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/924205.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-16
下一篇 2022-05-16

发表评论

登录后才能评论

评论列表(0条)

保存