自定義歡迎頁
Spring Boot 項(xiàng)目在啟動(dòng)后,首先會(huì)去靜態(tài)資源路徑下查找index.html作為首頁文件,若查找不到,則會(huì)去查找動(dòng)態(tài)的index文件作為首頁文件。例如,如果想使用靜態(tài)的index.html作為首頁,那么只需在resources/static 目錄下創(chuàng)建index.html 文件即可。若想使用動(dòng)態(tài)頁面作為項(xiàng)目首頁,則需在resources/templates 目錄下創(chuàng)建index.html (使用Thyme leaf 模板)或者index.ft! (使用FreeMarker 模板),然后在Controller 中返回邏輯視圖名,代碼如下:
1
2
3
4
|
@RequestMapping ( "/index" ) public String hello(){ return "index" ; } |
啟動(dòng)項(xiàng)目,輸入"http://localhost:8080/"就可以看到項(xiàng)目首頁的內(nèi)容
自定義favicon
favicon.ico 是瀏覽器選項(xiàng)卡左上角的圖標(biāo),可以放在靜態(tài)資源路徑下或者類路徑下,靜態(tài)資源路徑下的favicon.ico 優(yōu)先級(jí)高于類路徑下的favicon.ico 。
可以使用在線轉(zhuǎn)換網(wǎng)站https://jinaconvert.com/cn/convert-to-ico.php 將一張普通圖片轉(zhuǎn)為.ico 圖片,轉(zhuǎn)換成功后,將文件重命名為favicon.ico , 然后復(fù)制到resources/static 目錄下.
最后啟動(dòng)項(xiàng)目,就可以在瀏覽器選項(xiàng)卡中看到效果了.
去除自動(dòng)化配置
第一種:
@SpringBootApplication(exclude=WebMvcAutoConfiguration.class)
第二種:
在application.properties中配置:
spring-autoconfigure.exclude=要除去的類名
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://www.cnblogs.com/qiuwenli/p/13442706.html