您的位置:首页 > 运维架构 > 网站架构

Spring Boot 2.0 设置网站默认首页的实现代码

2018-04-02 17:24 615 查看

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 设置网站默认首页的实现代码,如果大家有任何疑问请给我留

言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息