![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SpringBoot
sofency
stay hungry stay foolish
展开
-
springBoot配置类的使用技巧
我们可以在配置中心application.yml中配置自定义的参数选项. 我们的需求是在程序运行的时候将集群的列表加载到代码中. 在application.yml中配置 zk. lists:[a,b,c] 创建bean @Data @Component //这样只是将该组建注册进容器 @ConfigurationProperties(prefix="cluster") public class Cluster{ private List<String> lists; } 我们想在项目中原创 2020-08-27 10:36:34 · 394 阅读 · 0 评论 -
springboot日志
slf4j使用 slf4j官方文档 The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks, such as java.util.logging, logback and log4j. SLF4J allows the end...原创 2020-02-20 21:31:42 · 117 阅读 · 0 评论 -
springboot配置文件加载位置以及自动配置原理
spring boot 启动会扫描以下位置的application.properties或者application.yml文件作为spring boot配置文件 file: ./config file: ./ classpath : /config/ classpath : / 以上是按照优先级从高到低的顺序,所有位置的文件都会被加载,高优先级位置内容会覆盖低优先级配置内容: 互补配置 ...原创 2020-02-20 15:24:17 · 654 阅读 · 0 评论 -
springboot多profile环境配置
springboot默认的配置文件是application.properties 和application.yml 对于上述两种默认的配置文件,springboot都有相应的多环境配置放置 对于application.properties文件来说 主要通过application-{profiles}.properties配置文件的方式进行配置环境 开发环境下的配置文件 application...原创 2020-02-20 11:28:54 · 152 阅读 · 0 评论 -
springboot2.2.4自定义全局异常
原理 springboot默认将错误的页面重定向到类路径下的/error目录下,我们需要在该目录下设置相应的状态码页面。无需配置springboot就会根据状态码找到相应的页面进行展示数据。在实现前后端分离的基础上我们选择thymeleaf模板引擎,类似于jsp但springboot不支持jsp的解析。 springboot对于thymeleaf模板解析时会自动到类路径下的/templates...原创 2020-02-03 14:07:50 · 1402 阅读 · 0 评论