为什么Java程序员必须要会SpringBoot?( 四 )


文章插图
 
9.Spring Boot 2.0 可以在 Tomcat 7 运行吗?为什么?
答:Spring Boot 2.0 无法在 Tomcat 7 上运行 。因为 Spring Boot 2.0 使用的是 Spring Framework 5,Spring Framework 5 使用的是 Servlet 3.1,而 Tomcat 7 最高支持到 Servlet 3.0,所以 Spring Boot 2.0 无法在 Tomcat 7 上运行 。
10.如何使用 Jetty 代替 Tomcat?
答:在 spring-boot-starter-web 移除现有的依赖项,添加 Jetty 依赖,配置如下:
‹dependency›    ‹groupId›org.springframework.boot‹/groupId›    ‹artifactId›spring-boot-starter-web‹/artifactId›    ‹exclusions›        ‹exclusion›            ‹groupId›org.springframework.boot‹/groupId›            ‹artifactId›spring-boot-starter-tomcat‹/artifactId›        ‹/exclusion›    ‹/exclusions›‹/dependency›‹dependency›    ‹groupId›org.springframework.boot‹/groupId›    ‹artifactId›spring-boot-starter-jetty‹/artifactId›‹/dependency›

为什么Java程序员必须要会SpringBoot?

文章插图
 
11.Spring Boot 不支持以下哪个内嵌容器?
A:TomcatB:JettyC:UndertowD:Nginx
答:D
题目解析:Jetty 容器支持如下:
‹dependency›   ‹groupId›org.springframework.boot‹/groupId›   ‹artifactId›spring-boot-starter-web‹/artifactId›   ‹exclusions›      ‹exclusion›         ‹groupId›org.springframework.boot‹/groupId›         ‹artifactId›spring-boot-starter-tomcat‹/artifactId›      ‹/exclusion›   ‹/exclusions›‹/dependency›‹dependency›   ‹groupId›org.springframework.boot‹/groupId›   ‹artifactId›spring-boot-starter-jetty‹/artifactId›‹/dependency›
为什么Java程序员必须要会SpringBoot?

文章插图
 
Undertow 容器支持如下:
‹dependency›    ‹groupId›org.springframework.boot‹/groupId›    ‹artifactId›spring-boot-starter-web‹/artifactId›    ‹exclusions›        ‹exclusion›            ‹groupId›org.springframework.boot‹/groupId›            ‹artifactId›spring-boot-starter-tomcat‹/artifactId›        ‹/exclusion›    ‹/exclusions›‹/dependency›‹dependency›    ‹groupId›org.springframework.boot‹/groupId›    ‹artifactId›spring-boot-starter-undertow‹/artifactId›‹/dependency›
为什么Java程序员必须要会SpringBoot?

文章插图
 
12.Spring Boot 中配置文件有几种格式?
答:Spring Boot 中有 .properties 和 .yml 两种配置文件格式,它们主要的区别是书写格式不同 。
.properties 配置文件格式如下:
app.user.name = hellojava.yml 配置文件格式如下:
app:    user:        name: hellojava13.项目中有两个配置 application.properties 和 application.yml,以下说法正确的是?
A:application.properties 的内容会被忽略,只会识别 application.yml 的内容 。B:两个配置文件同时有效,有相同配置时,以 application.properties 文件为主 。C:application.yml 的内容会被忽略,只会识别 application.properties 的内容 。D:两个配置文件同时有效,有相同配置时,以 application.yml 文件为主 。
答:B


推荐阅读