0% found this document useful (0 votes)
14 views

Spring Quetions-1

Spring Boot CLI is a command-line tool that can be used to create, run, and manage Spring Boot applications. The most used CLI commands are -run, -test, -jar, -war, and –init. Basic Spring Boot annotations include @SpringBootApplication, @Configuration, @Component, @RestController, and @RequestMapping.

Uploaded by

Mujif Attar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Spring Quetions-1

Spring Boot CLI is a command-line tool that can be used to create, run, and manage Spring Boot applications. The most used CLI commands are -run, -test, -jar, -war, and –init. Basic Spring Boot annotations include @SpringBootApplication, @Configuration, @Component, @RestController, and @RequestMapping.

Uploaded by

Mujif Attar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

11. What are Spring Boot CLI and the most used CLI commands?

Spring Boot CLI is a command-line tool that can be used to create, run, and manage
Spring Boot applications. It is a powerful tool that can help us to get started with Spring
Boot quickly and easily. It is built on top of the Groovy programming language.

Most used CLI commands are:

-run

-test

-jar

-war

–init

-help

Spring Boot Interview Questions for Intermediate


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

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

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

The simple way is to set the server. port property in your application’s
application.properties file. For example, to set the port to 8081, add the following
property to the application.properties file:

server.port=8081

15. 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 types of applications. These starters include,

Dependencies

Version control

Configuration needed to make certain features.

To use a Spring Boot starter dependency, we simply need to add it to our project’s
pom.xml file. For example, to add the Spring Boot starter web dependency, add the
following dependency to the pom.xml file:

16. 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 your application’s
application.properties file.

17. 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’s application.properties
file.

18. 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})

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

20. Describe the flow of HTTPS requests through the Spring Boot application.

The flow of HTTPS requests through a Spring Boot application is as follows:

First client makes an HTTP request (GET, POST, PUT, DELETE) to the browser.

After that the request will go to the controller, where all the requests will be mapped and
handled.

After this in Service layer, all the business logic will be performed. It performs the
business logic on the data that is mapped to JPA (Java Persistence API) using model
classes.

In repository layer, all the CRUD operations are being done for the REST APIs.

A JSP page is returned to the end users if no errors are there.

You might also like