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

springboot_notes

Uploaded by

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

springboot_notes

Uploaded by

Mahesh More
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1) what is advantage of spring boot ?

=>1. It is easy to learn every beginner developer


2. production ready feature
3. standalone application
4. it embed tomcat and jetty
5. rapid development

2) what is spring boot key component ?


=>1. Spring boot starter
2. spring boot Auto-configuration
3. spring boot CLI
4. spring boot Actuator

3) why spring boot over spring ?


=>1) Auto-Configuration
2) Standalone Applications : because embed server like tomcat and jetty
3) Minimal Configuration
4) Production-Ready Features : monitor and manage application
5) Spring Boot Starters : it provide set of starter web
6) Spring Boot CLI : it improve productivity of your application.
7) Embedded Server Support

4) what is starter dependency of spring boot module ?

=>a starter dependency is a pre-configured set of dependencies that provides a convenient


way to set up common modules in your application.
Ex. spring-boot-starter-web , spring-boot-starter-data-jpa , spring-boot-starter-thymeleaf,
spring-boot-starter-test, spring-boot-starter-security

5) how does spring boot work ?

=>1) Project Initialization


2) Application Starts
3) Auto-Configuration
4) Externalized Configuration
5) Production-Ready Features

6) what does the @springbootapplication annotation do internally?

=> annotation in Spring Boot is a composite annotation, which means that it combines
multiple important annotations to make setting up a Spring Boot application
Like . @Configuration, @EnableAutoConfiguration, @ComponentScan,
7) what is purpose of using @ComponentScan in the class file ?
=>@ComponentScan, which automatically scans the current package and sub-packages for
Spring components.
8) how does spring boot application get started ?

=>A Spring Boot application gets started in a straightforward and automated manner. The
process involves initializing the Spring application context, configuring necessary
components, and starting the application with an embedded server
1) @SpringBootApplication
2) SpringApplication.run()
3) Spring Boot Actuator
4) Externalized Configuration
5) Shutting Down the Application
9) what is spring initializer.
=> Spring Initializr is a web-based tool provided by Spring that helps developers quickly
generate a Spring Boot project with a specific configuration.

10) what is spring boot CLI ?


Spring Boot CLI (Command-Line Interface) is a command-line tool provided by Spring Boot
that allows developers to quickly run and test Spring Boot applications without the need for
an IDE or packaging the application into a JAR/WAR file.
Like spring run MyApp.java
spring install myapp.java
spring help
spring version

11) what are the basic annotation spring boot offer ?


=> 1. @SpringBootApplication
2. @RestController
3. @Controller
4. @Repository
5. @Entity
6. @Service
7. @Componant
8. @Configuration
9. @Bean
10. @Auto-Configuration
11. @PostMapping, @GetMapping, @RequestMapping, @PutMapping,
@DeleteMapping

12) what is spring boot dependency management.


=>Spring Boot Dependency Management is an essential feature that simplifies and
automates the management of project dependencies. It allows you to easily manage the
versions of libraries and dependencies your project
Like Starter POM project object model

13) Can we create non web application in spring boot.


=>yes
Create a Command-Line Application (CLI)
Spring Boot provides a simple mechanism for creating command-line applications (CLI)
without needing a web layer.

14) It is possible to change the port of the embedded tomcat server in spring boot ?

=> yes , it is possible to change port address in spring boot inside the application.properties
File like Server.port=8081

15) what is default port of tomcat in spring boot ?

=> 8080
16) Can we override or replace embedded tomcat server in spring boot ?
=> yes , To replace Tomcat with Jetty, you need to exclude the Tomcat dependency and
include the Jetty dependency in your pom.xml
17) Can we disable the default web server in the spring boot application ?
=> Yes , by adding property in application.properties folder spring.main.web-application-
type=none.

18) how to disable specific auto configuration class ?


=> there are different way such as,
@EnableAutoConfiguration or @springbootapplication
Application.properties
=>spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceA
utoConfiguration
19) explain @RestController annotation in spring boot ?
=>It is primarily used for creating RESTful web services that return data directly to the client
in formats like JSON or XML,
combines the behavior of two other annotations: @Controller and @ResponseBody

20) difference between @controller and @restcontroller ?


=>controllers that handle incoming HTTP requests,
Feature @Controller @RestController

Primary Used for MVC applications Used for REST APIs (serving raw
Use (serving views) data like JSON )
Default Returns views (e.g., Automatically serializes data to
Behavior HTML, JSP) JSON or XML

Requires @ResponseBody on @ResponseBody is implicit


Annotations on all methods
methods for raw data
21) where do we define properties in a spring boot application.

=> inside application.properties file

22) how to check environment properties in spring boot application ?


=>using environment object, @value
23) what is use of profile in springboot ?
=> In Spring Boot, a profile is a way to define different configurations for different
environments (such as development, testing, production, etc.
application-dev.properties for development
application-test.properties for testing
application-prod.properties for production
application.properties or application.yml:
properties
spring.profiles.active=dev
24) how to get list of all bean in your spring boot application ?
=>Using ApplicationContext to List Beans
Using CommandLineRunner to Print Beans on Startup
25) how to enable debugging log in spring boot application ?

=>Using application.properties
logging.level.root=DEBUG
logging.level.org.springframework.security=DEBUG
logging.level.com.example.myapp=DEBUG

Using Command Line Arguments

26) difference between Request Mapping and Get Mapping ?


=>
Feature @RequestMapping @GetMapping

Type of Can map any HTTP request (GET, Specifically for HTTP
Request POST, PUT, DELETE, etc.) GET requests

More flexible, can specify multiple More concise for GET


Flexibility requests
HTTP methods

Requires specifying method if No need method


Syntax (defaults to GET)
needed
Common Use General use when dealing with Best used when only
Case multiple HTTP methods handling GET requests

27) how to enable spring boot actuator in spring boot ?

=> Spring Boot Actuator provides production-ready features such as monitoring, metrics,
health checks, and more.
1. Add Spring Boot Actuator Dependency
2. Enable and Configure Endpoint
3. Accessing Actuator Endpoints
4. Example of a Full Configuration

28) Spring boot IOC

=> spring boot IOC stand for Inversion of controller, it is create object and configure and
assemble dependencies and manage entire life cycle

29) spring boot dependencies injection ?

=> spring boot depencies injection is a design pattern that allow developer to build application
that are easier to test, maintain and loosely coupled.

30) @Autowired configuration

=> @Autowired configuration is use to atomatically configure external class like repositore

31) how to call Rest Api in a spring boot ?

=>Rest stand for Representation state transfer protocol


In a spring boot rest api call using @RestController annotation
@RestController annotation is use to call rest full web service in spring boot
Rest api represented data in a JSON or xml format
Ex.
@GetMapping(“/”)
Public String restapi()
{
Return “ I am a RestFull Api”;
}

32) feature of spring boot ?

1) Auto-configuration
2) CLI
3) Actuator
4) embedded server
33) . What are the differences between @SpringBootApplication and @EnableAutoConfiguration
annotation?

@SpringBootApplication @EnableAutoConfiguration

1 user auto-configuration 1. Customized auto configuration


2. main class 2. Configuration class

You might also like