提交 bd764da8 编写于 作者: zlt2000's avatar zlt2000

增加自定义banner

上级 828fdfa7
......@@ -41,6 +41,7 @@
<userAgent.version>1.21</userAgent.version>
<transmittable.version>2.11.0</transmittable.version>
<lettuce.version>5.1.8.RELEASE</lettuce.version>
<banner.versio>1.0.2</banner.versio>
<platform-bom>Cairo-SR3</platform-bom>
<spring-cloud-alibaba-dependencies.version>2.0.0.RELEASE</spring-cloud-alibaba-dependencies.version>
<spring-boot-dependencies.version>2.0.9.RELEASE</spring-boot-dependencies.version>
......@@ -309,6 +310,11 @@
<artifactId>lettuce-core</artifactId>
<version>${lettuce.version}</version>
</dependency>
<dependency>
<groupId>com.nepxion</groupId>
<artifactId>banner</artifactId>
<version>${banner.versio}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -83,5 +83,10 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.nepxion</groupId>
<artifactId>banner</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.central.common.config;
import com.central.common.constant.CommonConstant;
import com.central.common.utils.CustomBanner;
import com.nepxion.banner.BannerConstant;
import com.nepxion.banner.Description;
import com.nepxion.banner.LogoBanner;
import com.taobao.text.Color;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* Banner初始化
*
* @author zlt
* @date 2019/8/28
*/
public class BannerInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
if (!(applicationContext instanceof AnnotationConfigApplicationContext)) {
LogoBanner logoBanner = new LogoBanner(BannerInitializer.class, "/zltmp/logo.txt", "Welcome to zlt", 5, 6, new Color[5], true);
CustomBanner.show(logoBanner, new Description(BannerConstant.VERSION + ":", CommonConstant.PROJECT_VERSION, 0, 1)
, new Description("Gitee:", "https://gitee.com/zlt2000/microservices-platform", 0, 1)
, new Description("Blog:", "https://blog.csdn.net/zlt2000", 0, 1)
);
}
}
}
......@@ -7,6 +7,11 @@ package com.central.common.constant;
* @date 2018/10/29
*/
public interface CommonConstant {
/**
* 项目版本号(banner使用)
*/
String PROJECT_VERSION = "2.5.0";
/**
* token请求头名称
*/
......
package com.central.common.utils;
import com.nepxion.banner.BannerConstant;
import com.nepxion.banner.Description;
import com.nepxion.banner.DescriptionBanner;
import com.nepxion.banner.LogoBanner;
import java.util.ArrayList;
import java.util.List;
/**
* @author zlt
* @date 2019/8/28
*/
public class CustomBanner {
public static void show(LogoBanner logoBanner, Description... descriptionList) {
String bannerShown = System.getProperty(BannerConstant.BANNER_SHOWN, "true");
if (!Boolean.valueOf(bannerShown)) {
return;
}
System.out.println("");
String bannerShownAnsiMode = System.getProperty(BannerConstant.BANNER_SHOWN_ANSI_MODE, "false");
if (Boolean.valueOf(bannerShownAnsiMode)) {
System.out.println(logoBanner.getBanner());
} else {
System.out.println(logoBanner.getPlainBanner());
}
List<Description> descriptions = new ArrayList<>();
for (Description description : descriptionList) {
descriptions.add(description);
}
DescriptionBanner descriptionBanner = new DescriptionBanner();
System.out.println(descriptionBanner.getBanner(descriptions));
}
}
org.springframework.context.ApplicationContextInitializer=\
com.central.common.config.BannerInitializer
\ No newline at end of file
________
| /
`---/ /
/ /
/ /----.
/________|
__
| |
| |
| |
| `----.
|_______|
.___________.
| |
`---| |----`
| |
| |
|__|
.___ ___.
| \/ |
| \ / |
| |\/| |
| | | |
|__| |__|
.______
| _ \
| |_) |
| ___/
| |
| _|
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册