spring boot设置默认首页,方法实验ok如下
附上application启动代码
/** * @classname application * @description spring-boot website启动类 * @author kevin.tian * @date 2018-03 * @version 1.0.0 */ @springbootapplication @propertysource(value={ "file:${app_home_conf}/overpayment-web/overpayment-web.properties", "file:${app_home_conf}/overpayment-web/db.properties" }) @importresource({"file:${app_home_conf}/overpayment-web/spring.xml"}) public class application extends springbootservletinitializer { public static void main(string[] args) { try { springapplication.run(application.class); } catch (exception e) { // todo: handle exception e.printstacktrace(); } } }
1. 放置默认首页default.html,
位置在/src/main/resources/static/default.html
2. 增加indexcontroller控制器,设置index路由
测试结果,如下
下面看下spring boot 2.0 新特性
说了这么多,spring boot 2.0 和 1.0 比都有哪些变动和新特性呢?
•jdk最低要求1.8+,并支持1.9;
•支持spring webflux/webflux.fn响应式的web编程;
•提供spring data cassandra, mongodb, couchbase和redis的响应式自动配置及starter poms;
•支持嵌入式的netty;
•http/2的支持:tomcat, undertow and jetty;
•全新的体系结构,支持spring mvc、webflux和jersey;
•增强了micrometer集成,以atlas, datadog, ganglia, graphite, influx, jmx, new relic, prometheus, signalfx, statsd and wavefront为基础的度量指标;
•quartz调度支持;
•极大简化了安全自动配置;
总结
以上所述是小编给大家介绍的spring boot 2.0 设置网站默认首页的实现代码
如对本文有疑问, 点击进行留言回复!!
最简单的在IntelliJ IDEA导入一个本地项目教程(图文)
Javaweb工程运行报错HTTP Status 404解决办法
Spring boot调用Oracle存储过程的两种方式及完整代码
网友评论