spring boot (1):初尝

工具:intellij idea

 

自定义banner:

控制台console显示的banner 自定义方式,在src/main/resources 下创建banner.txt增加文本即可,生成字符网站:http://patorjk.com/software/taag/

 

关闭banner:

     SpringApplication app = new SpringApplication(XiebangApplication.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run();

 

自制SSL(tomcat) 证书:

https://www.jianshu.com/p/8d4aba3b972d

关于生成keytool 文件请移步至上面的转载链接。

tip:最新版的spring boot 已经删除了EmbeddedServletContainerFactory

@Bean
    public Connector connector(){
//        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        Connector connector = new Connector(Http11NioProtocol.class.getName());
        connector.setScheme("http");
        connector.setPort(80);
        connector.setSecure(false);
        connector.setRedirectPort(443);
        return connector;
    }

    @Bean
    public TomcatServletWebServerFactory servletWebServerFactory(){
        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(){
            @Override
            protected void postProcessContext(Context context) {
                // 安全约束
                SecurityConstraint securityConstraint = new SecurityConstraint();
                securityConstraint.setUserConstraint("CONFIDENTIAL");
                SecurityCollection collection = new SecurityCollection();
                collection.addPattern("/");
                securityConstraint.addCollection(collection);
                context.addConstraint(securityConstraint);
            }
        };
        tomcat.addAdditionalTomcatConnectors(connector());
        return tomcat;
    }

 

关闭favicon:

spring.mvc.favicon.enabled = false

设置自定义favicon:

http://www.bitbug.net/

 

posted @ 2019-04-08 19:10  李鹏飞ONLINE  阅读(276)  评论(0编辑  收藏  举报