Java Spring Boot & Microservices | Java Spring Boot & Microservices Interview Questions Set - 2
Q11. How to Change the Default Port in Spring Boot?
Default port cane be changed in 3 ways first, by defining server.port in application properties file second, by setting server.port in SpringBootApplication main class third, by setting server.port while application running as jar file from command line.
Q12. How to configure properties in Spring Boot Application?
Configuration of properties in Spring Boot Application can be done either by using Property or YAML file. YAML is more readable for hierarchical configuration data.
Q13. What is the advantage with DevTools in Spring Boot.?
DevTools in Spring Boot will improve the development time while working on Spring Boot applications. While development spring boot application will restart automatically for any code changes, to get this feature spring-boot-devtools dependency needs to be added.
Q14. How to ignore null values in JSON response in spring boot?
To ignore null values in JSON response, use @JsonIgnore annotation. The field can be ignored while reading JSON into Java objects as well as while writing Java objects into JSON.
Q15. Basic Features of Spring Boot.?
Spring Boot has basic features like set of dependencies as starters, and the capability of providing Auto-Configuration and Spring Initializer from Spring core modules.
Q16. How to avoid exclude auto-configuration classes in Spring Boot.?
Spring Boot provided the flexibility to avoid one or more auto-configuration classes with the help of exclude attribute or attribute Name(which are not in class path) and adding the property in property file like spring.autoconfigure.exclude.
Q17. What is the use of Spring Initializer in Spring Boot.?
Spring Boot Initializer helps in rapid application development by providing Spring Boot Project with all required project structure/skeleton including dependencies without creating the project structure explicitly.
Q18. What is Live Reload in Spring Boot?
Live Reload is a spring-boot-devtools module that includes Live Reload server to trigger a browser refresh when a resource is changed. Live Reload server extensions are available freeware for Firefox, Chrome, etc.
Q19. How to Handle Exceptions in Spring Boot Application.?
Exceptions in the Spring Boot Application can be handled by using @ControllerAdvice and @ExceptionHandler to create generic or application specific exceptions. @ControllerAdvice returns the created exception as response to represent the exception type.
Q20. How do you generate a Spring Boot Application?
One of the ways to generate the Spring Boot based Project is using Spring Initializer by visiting spring.io by selecting appropriate parameters and another way is to use Spring Tools 4 for Eclipse (IDE) and generate a Spring Boot Project direct inside IDE.