您当前的位置: 首页 >  spring boot

梁云亮

暂无认证

  • 2浏览

    0关注

    1211博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Spring Boot 常用配置

梁云亮 发布时间:2020-02-01 00:02:03 ,浏览量:2

自定义 Banner

在 Spring Boot 启动的时候会有一个默认的启动图案

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)

我们在 src/main/resources 目录下新建一个 banner.txt

通过 http://patorjk.com/software/taag 网站生成字符串,将网站生成的字符复制到 banner.txt 中

再次运行这个程序

${AnsiColor.BRIGHT_RED}

//                          _ooOoo_                               //
//                         o8888888o                              //
//                         88" . "88                              //
//                         (| ^_^ |)                              //
//                         O\  =  /O                              //
//                      ____/`---'\____                           //
//                    .'  \\|     |//  `.                         //
//                   /  \\|||  :  |||//  \                        //
//                  /  _||||| -:- |||||-  \                       //
//                  |   | \\\  -  /// |   |                       //
//                  | \_|  ''\---/''  |   |                       //
//                  \  .-\__  `-`  ___/-. /                       //
//                ___`. .'  /--.--\  `. . ___                     //
//              ."" '<  `.___\__/___.'  >'"".                  //
//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
//      ========`-.____`-.___\_____/___.-`____.-'========         //
//                           `=---='                              //
//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
//            佛祖保佑       永不宕机     永无BUG                  //

常用属性设置:

  • ${AnsiColor.BRIGHT_RED}:设置控制台中输出内容的颜色
  • ${application.version}:用来获取 MANIFEST.MF 文件中的版本号
  • ${application.formatted-version}:格式化后的 ${application.version} 版本信息
  • ${spring-boot.version}:Spring Boot 的版本号
  • ${spring-boot.formatted-version}:格式化后的 ${spring-boot.version} 版本信息
Starter POM

Spring Boot 为我们提供了简化企业级开发绝大多数场景的 starter pom ,只要使用了应用场景所需要的 starter pom ,相关的技术配置将会消除,就可以得到 Spring Boot 为我们提供的自动配置的 Bean。

更多 Starter POM

日志配置

Spring Boot 对各种日志框架都做了支持,我们可以通过配置来修改默认的日志的配置

默认情况下,Spring Boot 使用 Logback 作为日志框架

logging:
  file: ../logs/spring-boot-hello.log
  level.org.springframework.web: DEBUG
关闭特定的自动配置

关闭特定的自动配置使用 @SpringBootApplication 注解的 exclude 参数即可,这里以关闭数据源的自动配置为例

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
关注
打赏
1665409997
查看更多评论
立即登录/注册

微信扫码登录

0.0412s