基于SpringBoot框架的程序开发步骤
熟练使用SpringBoot配置信息修改服务器配置
基于SpringBoot的完成SSM整合项目开发
框架常见的配置文件有哪几种形式?
http://localhost:8080/books/1 >>> http://localhost/books/1
SpringBoot提供了多种属性配置方式
xxxxxxxxxx
server.port=80
xxxxxxxxxx
server port81
xxxxxxxxxx
server port82
操作步骤:


注意事项:
什么是yaml,和properties有什么区别?
YAML(YAML Ain't Markup Language),一种数据序列化格式
优点:
YAML文件扩展名


xxxxxxxxxx
public class Enterprise { private String name; private Integer age; private String tel; private String[] subject; //自行添加getter、setter、toString()等方法}


xxxxxxxxxx
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional></dependency>
在实际开发中,项目的开发环境、测试环境、生产环境的配置信息是否会一致?如何快速切换?

xxxxxxxxxx
#主启动配置文件 application.propertiesspring.profiles.active=pro
xxxxxxxxxx
#环境分类配置文件 application-pro.propertiesserver.port=80
xxxxxxxxxx
#环境分类配置文件 application-dev.propertiesserver.port=81
xxxxxxxxxx
#环境分类配置文件application-test.propertiesserver.port=82
xxxxxxxxxx
java –jar springboot.jar --spring.profiles.active=testjava –jar springboot.jar --server.port=88java –jar springboot.jar --server.port=88 --spring.profiles.active=test

Maven与SpringBoot多环境兼容(步骤)
①:Maven中设置多环境属性
xxxxxxxxxx
<profiles> <profile> <id>dev_env</id> <properties> <profile.active>dev</profile.active> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>pro_env</id> <properties> <profile.active>pro</profile.active> </properties> </profile> <profile> <id>test_env</id> <properties> <profile.active>test</profile.active> </properties> </profile></profiles>
②:SpringBoot中引用Maven属性

③:执行Maven打包指令

④:对资源文件开启对默认占位符的解析
xxxxxxxxxx
<build> <plugins> <plugin> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>utf-8</encoding> <useDefaultDelimiters>true</useDefaultDelimiters> </configuration> </plugin> </plugins></build>

SpringBoot的配置文件可以放在项目的哪些地方?

xxxxxxxxxx
java –jar springboot.jar --spring.profiles.active=test --server.port=85 --server.servlet.context-path=/heima --server.tomcat.connection-timeout=-1 ... ...
SpringBoot中4级配置文件
1级: file :config/application.yml 【最高】
2级: file :application.yml
3级:classpath:config/application.yml
4级:classpath:application.yml 【最低】
作用:
1级与2级留做系统打包后设置通用属性
3级与4级用于系统开发阶段设置通用属性