springboot入门知识点(一)

1.idea快捷键 

 ctrl+H   //全局搜索

2.springboot知识点

 

   父级依赖可以不用写版本号

3.注解

 1> @SpringBootApplication:springboot的核心注解,开启spring自动配置,开启自动扫描

 建包必须和Application是同一级别,不然controller扫描不到

 2>@Controller

 3>@ResController -- 是@Controller和@ResponseBody组合的注解,用于返回String字符串和json数据   (class中使用@ResController  方法无需使用@ResponseBody 只需使用 @RequestMapper注解 )(如果要返回页面,则改为@Controller)

 

 4>@GetMapping  -- @RequestMapper 和 get请求的组合

 

 5>@PostMapping  -- @RequestMapper 和 post请求的组合(目前浏览器不支持)

4.启动

 在Application 中main方法启动

5.springboot核心配置文件

  .properties:键值队配置 ----  server.port = 6666  :内嵌tomcat端口号

                      ---- server.context-path= 路径  :访问路径(项目上下文)

  .yml:数据库的配置(控制和换行排版)

                     ---- server: 空格  enter键  tab键  port:空格6666

                       server:

                         port: 6666

                        context-path: 路径

  .properties 和 .yml 不能同时存在 ,.properties优先

6,springboot多文件配置

   application-test.properties  测试配置文件

   application-dev.properties  开发配置文件

   application-online.properties 上线配置文件

   在application.properties中

            spring.profiles.active=test  ---激活测试文件  (激活配置优先)

7.自定义配置

  在application.properties中

   boot.name = 北京

   boot.location = 大新

  在controller中

 

8.乱码问题

  file -- setting -- file encoding -- 统一为utf-8

9.application配置文件

  1>配置前缀和后缀

  2> xml配置文件

 

  3>数据库配置连接信息

 

 4>beetl配置路径

 

10.pom文件

  1>访问jsp页面

 

11.springboot 集成mybaties

 

12.maven创建springboot

  file-new-module-maven(jdk--1.8)-(add as && parent 选择none  version-1.0.0)-finsh

 

猜你喜欢

转载自www.cnblogs.com/xinzhihen/p/9547767.html
今日推荐