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.

//不觉得 yml 有优势,Some developers find it difficult to use for its complex indentation formatting。

//https://www.csestack.org/advantages-disadvantages-yaml/

 

  • 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

//具体的代码例子?

 

@Configuration
@Profile("production")
public class ProductionConfiguration {

    // ...

}

 

 

  • 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.

//举例说明?

icon 的位置 :  src/main/resources/favicon.ico

// http://www.baeldung.com/spring-boot-favicon

// https://javadeveloperzone.com/spring-boot/spring-boot-set-favicon-icon/

 

  • 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.

//这个error 在哪里?写个project, 自定义一下

//http://www.baeldung.com/spring-boot-custom-error-page

//http://blog.didispace.com/springbootexception/

 

  • 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

//代码实现?

//https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html

//https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/

//https://stormpath.com/blog/tutorial-spring-boot-war-files

posted @ 2018-06-17 14:53  VickyFengYu  阅读(127)  评论(0编辑  收藏  举报