Spring Boot Questions- Part 2

Posted VickyFengYu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot Questions- Part 2相关的知识,希望对你有一定的参考价值。

  • What is spring-boot-devtools ?

Applications that use spring-boot-devtools will automatically restart whenever files on the classpath change. This can be a useful feature when working in an IDE as it gives a very fast feedback loop for code changes.

// spring-boot-devtools 怎么使用,有哪些选项?

 

  • What is LiveReload?

The spring-boot-devtools module includes an embedded LiveReload server that can be used to trigger a browser refresh when a resource is changed. LiveReload browser extensions are freely available for Chrome, Firefox and Safari from livereload.com.

Read More spring boot devtools 

//可以了解一下 LiveReload 的工作原理机制

//插件了解一下,写blog

 

  • How to exclude auto restart for static files?

By default changing resources in /META-INF/maven, /META-INF/resources, /resources, /static, /public or /templates will not trigger a restart
But If you want to customize these exclusions you can use the spring.devtools.restart.exclude property
if you want to keep those defaults and add additional exclusions, use the spring.devtools.restart.additional-exclude property instead

Read More spring boot devtools

 

  • How to start spring boot application in debug mode?

java -jar myproject-0.0.1-SNAPSHOT.jar –debug

 

  • What are the advantages of YAML file than Properties file?

YAML is a superset of JSON, and as such is a very convenient format for specifying hierarchical configuration data. The SpringApplication class will automatically support YAML as an alternative to properties whenever you have the SnakeYAML library on your classpath.

 

  • What are the different ways to load YAML file in Spring boot?

1. YamlPropertiesFactoryBean will load YAML as Properties
2. YamlMapFactoryBean will load YAML as a Map

 

  • What are the advantages of spring Externalized Configuration?

Externalize your configuration to work with the same application code in different environments. You can use properties files, YAML files, environment variables and command-line arguments to externalize configuration.

 

  • What are Profiles in spring boot?

Spring Profiles provide a way to segregate parts of your application configuration and make it only available in certain environments. Any @Component or @Configuration can be marked with @Profile to limit when it is loaded

 

  • How to write custom log configuration in spring boot?

You can force Spring Boot to use a particular logging system using the org.springframework.boot.logging.LoggingSystem system property. The value should be the fully-qualified class name of a LoggingSystem implementation. You can also disable Spring Boot’s logging configuration entirely by using a value of none.

 

  • How do you customize Favicon in spring boot web application?

Spring Boot looks for a favicon.ico in the configured static content locations and the root of the classpath (in that order). If such file is present, it is automatically used as the favicon of the application.

 

  • How spring boot handles error in application?

Spring Boot provides an /error mapping by default that handles all errors in a sensible way, and it is registered as a ‘global’ error page in the servlet container.

 

  • How do you Create a deployable war file in spring boot?

Step1: Extend SpringBootServletInitializer and override its configure method
Step 2: Change packing type to war in pom.xml or in build.gradle
Step 3: Mark the embedded servlet container dependency as provided

以上是关于Spring Boot Questions- Part 2的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot Interview Questions

Spring Boot Questions- Part 1

Questions on Spring Boot – Part 3

Spring boot中使用jwt

Spring boot中使用jwt

Spring Boot @ConfigurationProperties使用指导