Styntax Error

1. What is Spring Initializer ?

Spring Initializer is a web application that helps you to create an initial spring boot project structure and provides a maven or gradle file to build your code. It solves the problem of setting up a framework when you are starting a project from scratch.

2. What are the steps in the Spring Bean Life Cycle ?

Spring Bean Life Cycle:
Instantiation: Creating the bean instance.
Population: Injecting dependencies.
Initialization: Calling @PostConstruct methods and custom init methods.
Ready for Use: The bean is now ready to be used.
Destruction: Calling @PreDestroy methods and custom destroy methods before the bean is removed from the container.

3. What are the most common Spring Boot CLI commands ?

-run, -test, -grap, -jar, -war, -install, -uninstall, –init, -shell, -help.

4. What is Spring Boot CLI and what are its benefits ?

Spring Boot CLI is a command-line interface that allows you to create a spring-based java application using Groovy.
Example: You don not need to create getter and setter method or access modifier, return statement. If you use the JDBC template, it automatically loads for you.

5. What is the difference between @RestController and @Controller in Spring Boot ?

@Controller Map of the model object to view or template and make it human readable but @RestController simply returns the object and object data is directly written in HTTP response as JSON or XML.

6. What is the main advantage of using Spring Boot ?

The main advantage of using Spring Boot is that it simplifies the setup and development of Spring applications by providing default configurations and reducing boilerplate code.

7. How do you create a simple Spring Boot application ?

To create a simple Spring Boot application, you can use Spring Initializr to generate a project with the necessary dependencies. Then, you can build and run the application using an embedded server like Tomcat or Jetty.

8. What is the @RestController annotation used in Spring Boot ?

The @RestController annotation is used to create RESTful web services using Spring MVC. It combines @Controller and @ResponseBody, eliminating the need to annotate each method with @ResponseBody.

9. What are the basic Spring Boot Annotations ?

@SpringBootApplication: This is the main annotation used to bootstrap a Spring Boot application. It combines three annotations: @Configuration , @EnableAutoConfiguration , and @ComponentScan . It is typically placed on the main class of the application.
@Configuration: This annotation is used to indicate that a class contains configuration methods for the application context. It is typically used in combination with @Bean annotations to define beans and their dependencies.
@Component: This annotation is the most generic annotation for any Spring-managed component. It is used to mark a class as a Spring bean that will be managed by the Spring container.
@RestController: This annotation is used to define a RESTful web service controller. It is a specialized version of the @Controller annotation that includes the @ResponseBody annotation by default.
@RequestMapping: This annotation is used to map HTTP requests to a specific method in a controller. It can be applied at the class level to define a base URL for all methods in the class, or at the method level to specify a specific URL mapping.

10. What is Spring Boot dependency management ?

Spring Boot dependency management makes it easier to manage dependencies in a Spring Boot project. It makes sure that all necessary dependencies are appropriate for the current Spring Boot version and are compatible with it.

11. Is it possible to change the port of the embedded Tomcat server in Spring Boot ?

Yes, it is possible to change the port of the embedded Tomcat server in a Spring Boot application.
Simply we can set the server.port property in application.properties file.For example
server.port=8081 // this is the part of application.property file.

12. What is the starter dependency of the Spring boot module ?

Spring Boot Starters are a collection of pre-configured maven dependencies that makes it easier to develop particular types of applications. These starters include,
Dependencies
Version control
Configuration needed to make certain features.

13. What is the default port of Tomcat in spring boot ?

The default port of the embedded Tomcat server in Spring Boot is 8080 . We can change the default port by setting the server.port property in application.properties file.

14. Can we disable the default web server in the Spring Boot application ?

Yes, we can disable the default web server in the Spring Boot application. To do this, we need to set the server.port property to “-1” in the application.properties file.

15. How to disable a specific auto-configuration class ?

To disable a specific auto-configuration class in a Spring Boot application, we can use the @EnableAutoConfiguration annotation with the ” exclude” attribute.

@EnableAutoConfiguration(exclude = {//classname})

16. Can we create a non-web application in Spring Boot ?

Yes, we can create a non-web application in Spring Boot. Spring Boot is not just for web applications. Using Spring Boot, we can create applications like Microservices, Console applications, and batch applications.

17. What are starter dependencies ?

Spring boot starter is a maven template that contains a collection of all the relevant transitive dependencies that are needed to start a particular functionality.
Like we need to import spring-boot-starter-web dependency for creating a web application.

<dependency>
<groupId> org.springframework.boot</groupId>
<artifactId> spring-boot-starter-web </artifactId>
</dependency>