在上手springboot之后,可以看到在 启动的时候,控制台会打印出关于springboot的信息,也就是显示出来SpringBoot默认的信息(横幅)。
在springboot的官方文档中指出,可以自定义属于自己的横幅。
https://docs.spring.io/spring-boot/docs/2.0.2.RELEASE/reference/htmlsingle/#boot-features-custom-log-levels 23.2 Customizing the Banner 自定义横幅
可以通过向banner.txt类路径添加文件或将spring.banner.location属性设置为此类文件的位置来更改启动时打印的横幅。如果文件的编码不是UTF-8,则可以进行设置spring.banner.charset。除了一个文本文件,你还可以添加一个banner.gif,banner.jpg或banner.png 图像文件到类路径或设置spring.banner.image.location属性。图像将转换为ASCII艺术表示,并打印在任何文本横幅上方。
在banner.txt文件中,您可以使用以下任何占位符:
Variable | Description |
${application.version} | The version number of your application, as declared in MANIFEST.MF. For example, Implementation-Version: 1.0 is printed as 1.0. |
${application.formatted-version} | The version number of your application, as declared in MANIFEST.MF and formatted for display (surrounded with brackets and prefixed with v). For example (v1.0). |
${spring-boot.version} | The Spring Boot version that you are using. For example 2.0.2.RELEASE. |
${spring-boot.formatted-version} | The Spring Boot version that you are using, formatted for display (surrounded with brackets and prefixed with v). For example (v2.0.2.RELEASE). |
${Ansi.NAME} (or ${AnsiColor.NAME}, ${AnsiBackground.NAME}, ${AnsiStyle.NAME}) | Where NAME is the name of an ANSI escape code. See AnsiPropertySource for details. |
${application.title} | The title of your application, as declared in MANIFEST.MF. For example Implementation-Title: MyApp is printed as MyApp. |
在项目的resources文件夹下新建一个banner.txt文件,或者自定义文件之后在application.property中指定文件路径。
自定义内容之后,重启项目就好了。
也可以在property文件中,禁止控制台显示banner内容:
spring.main.banner-mode=off