SpringBoot笔记 一

打开Idea-> new Project ->Spring Initializr ->填写group、artifact ->钩上web(开启web功能)->点下一步就行了。

    • pom文件为基本的依赖管理文件
    • resouces 资源文件 
      • statics 静态资源
      • templates 模板资源
      • application.yml 配置文件
    • SpringbootApplication程序的入口。

神奇之处:

  • 你没有做任何的web.xml配置。
  • 你没有做任何的sping mvc的配置; springboot为你做了。
  • 你没有配置tomcat ;springboot内嵌tomcat.

springboot采纳了建立生产就绪Spring应用程序的观点。Spring Boot优先于配置的惯例,旨在让您尽快启动和运行。

多个环境配置文件

在现实的开发环境中,我们需要不同的配置环境;格式为application-{profile}.properties,其中{profile}对应你的环境标识,比如:

  • application-test.properties:测试环境
  • application-dev.properties:开发环境
  • application-prod.properties:生产环境

怎么使用?只需要我们在application.yml中加:

spring:

 profiles:

  active: dev

其中application-dev.yml:

server:

 port: 8082

启动工程,发现程序的端口不再是8080,而是8082。

原文地址:https://www.cnblogs.com/xsj891107/p/7808948.html