SpringBoot框架Day01之核心与内嵌服务器HelloWorld和开发向导

核心!

场景starter - xxxxAutoConfiguration - 导入xxx组件 - 绑定xxxProperties – 绑定配置文件项

开始

内嵌服务器?springboot优势初体验!

  1. 创建maven工厂,pom中添加依赖
  2. 编写main函数,类上标明@SpringBootApplication
  3. Controller层 使用@RestController注解
  4. 在resource目录下创建配置文件application.properties
  5. 使用maven进行打包,通过命令行手动部署在Tomcat服务器中。cmd命令窗口下输入:
java -jar  springboot-1.0-SNAPSHOT.jar

springboot依赖管理与版本仲裁

之所以只引入一个spring-boot-starter-parent这个jar包,在spring-boot-dependencies中springboot当前版本自动为开发者实现jar包导入管理。若开发者向更改当前依赖jar包版本号,只需在pom文件中就近原则声明properties自定义修改版本号,实现版本仲裁。

包扫描

使用@SpringBootApplication(scanBasePackages=“com.lwt”)或者不使用前者(前者包含后者)使用@ComponentScan

自动配置原理

spring-boot-starter-web-2.3.4.RELEASE.pom到spring-boot-starter-2.3.4.RELEASE.pom到spring-boot-autoconfigure-2.3.4.RELEASE.pom

前期简单总结

  1. 引入依赖
  2. 查看自动配置 debug=true Negative/Positive
  3. application.properties配置参照
    https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#common-application-properties 官网。

开发技巧

  1. lombok @Data
  2. dev-tools
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
  1. spring-Initailizr 初始化向导,返璞归真。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值