1. What is Spring boot ?
Ans: Spring Boot is an open source Java-based framework used to create a Micro Service. It is developed by Pivotal Team. It is easy to create a stand-alone and production ready spring applications using Spring Boot.
2. What is Micro service ?
Ans: Micro Service is an architecture that allows the developers to develop and deploy services independently. Each service running has its own process and this achieves the lightweight model to support business applications.
3. What are the two advantages provided by microservices to its developers ?
Ans: Micro services offers the following advantages to its developers −
- Easy deployment
- Simple scalability
Spring Boot provides a good platform for Java developers to develop a stand-alone and production-grade spring application that you can just run.
4. What are the two basic goals of the spring boot ?
Ans: Spring Boot is designed with the following goals −
- To avoid complex XML configuration in Spring
- To develop a production ready Spring applications in an easier way
5. What are the features and benefits provided by the spring boot ?
Ans: You can choose Spring Boot because of the features and benefits it offers as given here −
- It provides a flexible way to configure Java Beans, XML configurations, and Database Transactions.
- It provides a powerful batch processing and manages REST endpoints.
6. What is handling dependency ?
Ans: Handling dependency management is a difficult task for big projects. Spring Boot resolves this problem by providing a set of dependencies for developers convenience.
7. What is the use of the spring boot starter actuator dependency ?
Ans: Spring Boot Starter Actuator dependency is used to monitor and manage your application.
8. What is the role of spring boot starter security dependency ?
Ans: Spring Boot Starter Security dependency is used for Spring Security.
9. What is the role of spring boot starter web dependency ?
Ans: Spring Boot Starter web dependency is used to write a Rest Endpoints.
10. What is the use of spring boot starter thyme leaf dependency ?
Ans: Spring Boot Starter Thyme Leaf dependency is used to create a web application.
11. What is the use of spring boot starter test dependency ?
Ans : Spring Boot Starter Test dependency is used for writing Test cases.
12. Who automatically configures your spring application based on the JAR dependencies you added in the project ?
Ans: Spring Boot Auto Configuration automatically configures your Spring application based on the JAR dependencies you added in the project.
13. What is spring boot cli ?
Ans: The Spring Boot CLI is a command line tool and it allows us to run the Groovy scripts. This is the easiest way to create a Spring Boot application by using the Spring Boot Command Line Interface.
14. How to bootstrapping a spring boot application ?
Ans: One of the ways to Bootstrapping a Spring Boot application is by using Spring Initializer.
15. Who provides a number of starters to add the jars in our class path ?
Ans: Spring Boot provides a number of Starters to add the jars in our class path.
16. Which class file allows you to configure the application when it is launched by using servlet container ?
Ans: Spring Boot Servlet Initializer class file allows you to configure the application when it is launched by using Servlet Container.
Note: For Maven, use the command mvn package for packaging your application. Then, the WAR file will be created and you can find it in the target directory.
A class that does not have any package declaration is considered as a default package.
17. What is @ComponentScan ?
Ans: The @ComponentScan annotation is used to find beans and the corresponding injected with @Autowired annotation.
18. What is Application runner ?
Ans: Application Runner is an interface used to execute the code after the Spring Boot application started.
19. What is Command line runner ?
Ans: Command Line Runner is an interface. It is used to execute the code after the Spring Boot application started.
20. Who convert the command line properties into spring boot environment properties ?
Ans: Spring Boot application converts the command line properties into Spring Boot Environment properties.
Note: Command line properties take precedence over the other property sources.
21.What is the use of properties files ?
Ans: Properties files are used to keep ‘N’ number of properties in a single file to run the application in a different environment. In Spring Boot, properties are kept in the application.properties file under the classpath.
22. Who supports YAML based properties configurations to run the application ?
Ans: Spring Boot supports YAML based properties configurations to run the application.
23. What is @value annotation ?
Ans: The @Value annotation is used to read the environment or application property value in Java code.
Note: Spring Boot supports different properties based on the Spring active profile.
24. What is the name of logging used by spring boot for all internal logging ?
Ans: Spring Boot uses Apache Commons logging for all internal logging. Spring Boot’s default configurations provides a support for the use of Java Util Logging, Log4j2, and Logback.
25. In spring boot, What are the different types of logger levels ?
Ans: Spring Boot supports all logger levels such as “TRACE”, “DEBUG”, “INFO”, “WARN”, “ERROR”, “FATAL”, “OFF”.
26. How to handle spring boot log configurations ?
Ans: Logback supports XML based configuration to handle Spring Boot Log configurations.
Note: For building a RESTful Web Services, we need to add the Spring Boot Starter Web dependency into the build configuration file.
27. What is @RestController annotation ?
Ans: The @RestController annotation is used to define the RESTful web services. It serves JSON, XML and custom response.
28. What is @Requestmapping annotation ?
Ans: The @RequestMapping annotation is used to define the Request URI to access the REST Endpoints. We can define Request method to consume and produce object. The default request method is GET.
29. What is @Requestbody annotation ?
Ans: The @RequestBody annotation is used to define the request body content type.
30. What is @Pathvariable annotation ?
Ans: The @PathVariable annotation is used to define the custom or dynamic request URI.
31. What is @RequestParam annotation ?
Ans: The @RequestParam annotation is used to read the request parameters from the Request URL. By default, it is a required parameter.
32. What is HTTP put request ?
Ans: The HTTP PUT request is used to update the existing resource. This method contains a Request Body. We can send request parameters and path variables to define the custom or dynamic URL.
33. What is HTTP Delete request ?
Ans: The HTTP Delete request is used to delete the existing resource. This method does not contain any Request Body. We can send request parameters and path variables to define the custom or dynamic URL.
34. What is @ControllerAdvice ?
Ans: The @ControllerAdvice is an annotation, to handle the exceptions globally.
35. What is @ExceptionHandler ?
Ans: The @ExceptionHandler is an annotation used to handle the specific exceptions and sending the custom responses to the client.
Note:
You can use the Interceptor in Spring Boot to perform operations under the following situations −
- Before sending the request to the controlle
- Before sending the response to the client
36. What are the three methods you should know while working on Interceptors ?
Ans: The following are the three methods you should know about while working on Interceptors −
- preHandle() method − This is used to perform operations before sending the request to the controller. This method should return true to return the response to the client.
- postHandle() method − This is used to perform operations before sending the response to the client.
- afterCompletion() method − This is used to perform operations after completing the request and response.
37. What is a filter ?
Ans: A filter is an object used to intercept the HTTP requests and responses of your application.
38. What is Rest template ?
Ans: Rest Template is used to create applications that consume RESTful Web Services. You can use the exchange() method to consume the web services for all HTTP methods.
39. What are the service components ?
Ans: Service Components are the class file which contains @Service annotation. These class files are used to write business logic in a different layer, separated from @RestController class file.
40. What is Thymeleaf ?
Ans: Thymeleaf is a Java-based library used to create a web application. It provides a good support for serving a XHTML/HTML5 in web applications.
41, What is CORS ?
Ans: Cross-Origin Resource Sharing (CORS) is a security concept that allows restricting the resources implemented in web browsers.
42. What is Internationalization ?
Ans: Internationalization is a process that makes your application adaptable to different languages and regions without engineering changes on the source code.
43. What is localechangeinterceptor ?
Ans: LocaleChangeInterceptor is a used to change the new Locale based on the value of the language parameter added to a request.
44. What is scheduling ?
Ans: Scheduling is a process of executing the tasks for the specific time period. Spring Boot provides a good support to write a scheduler on the Spring applications.
45. What is the use of Jave cron expression ?
Ans: Java Cron expressions are used to configure the instances of CronTrigger, a subclass of org.quartz.Trigger.
46. What is @Enablescheduling ?
Ans: The @EnableScheduling annotation is used to enable the scheduler for your application.
47. What is @Scheduled annotation ?
Ans: The @Scheduled annotation is used to trigger the scheduler for a specific time period.
48. What is Fixed rate scheduler ?
Ans: Fixed Rate scheduler is used to execute the tasks at the specific time. It does not wait for the completion of previous task.
49. What is Eureka server ?
Ans: Eureka Server is an application that holds the information about all client-service applications. Every Micro service will register into the Eureka server and Eureka server knows all the client applications running on each port and IP address. Eureka Server is also known as Discovery Server.
50. What is Zuul server ?
Ans: Zuul Server is a gateway application that handles all the requests and does the dynamic routing of microservice applications. The Zuul Server is also known as Edge Server.
51. What is spring cloud configuration server ?
Ans: Spring Cloud Configuration Server is a centralized application that manages all the application related configuration properties.
52. What is the spring boot actuator ?
Ans: Spring Boot Actuator provides secured endpoints for monitoring and managing your Spring Boot application. By default, all actuator endpoints are secured.
53. What is spring boot admin server ?
Ans: Spring Boot Admin Server is an application used to manage and monitor your Microservice application.
54. What is swagger2 ?
Ans: Swagger2 is an open source project used to generate the REST API documents for RESTful web services. It provides a user interface to access our RESTful web services via the web browser.
55. What is Zipkin ?
Ans: Zipkin is an application that monitors and manages the Spring Cloud Sleuth logs of your Spring Boot application.
56. What is Flyway ?
Ans: Flyway is a version control application to evolve your Database schema easily and reliably across all your instances.
57. What is Hystrix ?
Ans: Hystrix is a library from Netflix. Hystrix isolates the points of access between the services, stops cascading failures across them and provides the fallback options.
58. What is @EnableWebsocketmessagebroker ?
Ans: The @EnableWebSocketMessageBroker annotation is used to configure the Web socket message broker to create STOMP endpoints.
59. What is batch service ?
Ans: Batch Service is a process to execute more than one command in a single task.
60. What is Twilio ?
Ans: Twilio is a 3rd party application used to send SMS and make voice calls from our application. It allows us to send the SMS and make voice calls programmatically.
Note: For injecting Mockito Mocks into Spring Beans, we need to add the Mockito-core dependency in our build configuration file.
With the help of SpringJUnit4ClassRunner and MockMvc, we can create a web application context to write Unit Test for Rest Controller file.
61. What is Redis ?
Ans: Redis is an open source database used to store the in-memory data structure. To connect the Redis database in Spring Boot application, we need to add the Redis dependency in our build configuration file.
Note:
Spring Boot application automatically requires the Basic Authentication for all HTTP Endpoints. The Endpoint “/” and “/home” does not require any authentication. All other Endpoints require authentication.
62. What is Oauth2 ?
Ans: OAuth2 is an authorization framework that enables the application Web Security to access the resources from the client.
63. What is JWT token ?
Ans: JWT Token is a JSON Web Token, used to represent the claims secured between two parties.