增加自定义banner
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -7,6 +7,11 @@ package com.central.common.constant;
|
||||
* @date 2018/10/29
|
||||
*/
|
||||
public interface CommonConstant {
|
||||
/**
|
||||
* 项目版本号(banner使用)
|
||||
*/
|
||||
String PROJECT_VERSION = "2.5.0";
|
||||
|
||||
/**
|
||||
* token请求头名称
|
||||
*/
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
org.springframework.context.ApplicationContextInitializer=\
|
||||
com.central.common.config.BannerInitializer
|
||||
@@ -0,0 +1,30 @@
|
||||
________
|
||||
| /
|
||||
`---/ /
|
||||
/ /
|
||||
/ /----.
|
||||
/________|
|
||||
__
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| `----.
|
||||
|_______|
|
||||
.___________.
|
||||
| |
|
||||
`---| |----`
|
||||
| |
|
||||
| |
|
||||
|__|
|
||||
.___ ___.
|
||||
| \/ |
|
||||
| \ / |
|
||||
| |\/| |
|
||||
| | | |
|
||||
|__| |__|
|
||||
.______
|
||||
| _ \
|
||||
| |_) |
|
||||
| ___/
|
||||
| |
|
||||
| _|
|
||||
Reference in New Issue
Block a user