spring boot設置默認首頁,方法實驗ok如下
附上application啟動代碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/** * @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 設置網站默認首頁的實現代碼,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!
原文鏈接:http://www.cnblogs.com/itshare/p/8694595.html