sa Flashcards

1
Q

What is Spring boot?

A

Sprint boot is an extension of spring based framework used to quickly create Application
It has extra support of auto-configuration and embedded application server like tomcat, jetty, Undertow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the advantages of using Spring Boot?

A

1- Less configuration
2- Increases productivity and reduces development time by less amounts of source code;
3- don’t need to write any XML configuration, only a few annotations are required to do the configuration.
4- Helping to directly embed Tomcat, Jetty, or Undertow into an application;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the Spring Boot key components?

A

1- auto-configuration.
2- CLI.
3- starter POMs.
4- Actuators. (use to monitor our application)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why Spring Boot over Spring

A
1- Auto Configuration.
2- Started' POMs
3- Actuators
4- Component Scanning.
5- Embedded server.
6- InMemory DB.
7- Externalized Configuration

we need not to specify the version of the dependencies in our configuration. Spring Boot manages itself. Spring Boot upgrades all dependencies automatically

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

@Bean

A

@Bean is a method-level annotation

Used to explicitly declare a single bean in a configuration class.

The @Bean annotation tells Spring that a method annotated with @Bean will return an object that should be registered as a bean in the Spring application context.

Java based configuration: 
If you want to use a java based configuration then you have to use @Configuration annotation over your class which you will use to load the container. Now for the bean definition, you can do with in two.

a)In your configuration class @Bean annotations over the factory methods which you give you your bean objects by using the new keyword. and you have to add @Configuration over the class name

 @Bean 
   public HelloWorld helloWorld(){
      return new HelloWorld();
   }
b) @Component/@Service/@Repository/@Controller/@RestController over the class which you want to act as a bean.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does Spring Boot works?

A

1- The entry point of the spring boot application is the class that contains @SpringBootApplication annotation and the main method. spring boot has a main() and it calls static run()

2- Automatically scans all the components included in the project by using @ComponentScan annotation initialization the beans and package declarations

3- Automatically configures your application based on the dependencies you have added to the project by using annotation.

4-Spring Starter Dependencies (POM) to ensure that your application starts with the correct dependencies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are starter dependencies?

A

Starter POMs. is a maven template that contains a collection of all the relevant dependencies that are needed to start a particular functionality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s the Difference Between Spring Boot and Spring MVC?

A

Spring MVC requires

  • used for multi page application
  • manual build configurations,
  • use an application server.

Spring Boot

  • use for singel page application
  • auto configuration
  • embedded tomcat server
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

@Controller

A
  • The @Controller is a class-level annotation.
  • The @Controller annotation marks a class as a Spring MVC Controller
  • which allow the use of handler mapping annotations.
  • It is a specialization of @Component.
  • It marks a class as a web request handler.
  • It is often used to serve web pages.
  • By default, it returns a string that indicates which route to redirect.
  • It is mostly used with @RequestMapping annotation.
@Controller  
public class BooksController   
{  
@RequestMapping("/computer-science/books")  
public String getAllBooks(Model model)  
{  
//application code  
return "bookList";  
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stereotype Annotations

A
the stereotype annotations in spring are a number of built in annotations @Component, @Service, @Repository, and @Controller. @Component is a class-level annotation. 
It is used to indicate, a class as a Component. 
We can use @Component across the application to mark the beans as Spring's managed components

Spring will automatically import the beans into the container and inject to dependencies. … These annotations are called Stereotype annotations as well.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

@Component

A

It is a class-level annotation

It means that Spring framework will autodetect these classes for dependency injection when annotation-based configuration and class path scanning is used.

@Service , @Repository , @Controller(MVC) already have embedded @Component

@Component is a generic stereotype for any Spring-managed component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

@Repository

A
It is a class-level annotation. 
The @Repository annotation marks a class to be used as repository DAOs (Data Access Object) that access the database directly.  use all the operations related to the database.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

@Service

A
It is a class level annotation. 
it marks a class as a Service for an application
It tells the Spring that class contains the business logic.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

@Configuration

A

the @Configuration indicates that the class can be used by the Spring IoC (Inversion of Control) container as a source of bean definitions.

@Configuration
public class AppConfig {
@Bean(name="demoService")
public DemoClass service() 
{

} }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

@EnableAutoConfiguration:

A

It auto-configures the bean that is present in the classpath and configures it to run the methods.
The use of this annotation is reduced in Spring Boot release because developers provided an alternative of the annotation, i.e. @SpringBootApplication.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

@Required Annotation

A

Spring @Required annotation is applicable to bean property setter methods

@Required
public void setName(String name) {
this.name = name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

@Autowired

A

It is used for dependency injection.
In spring boot application, all loaded beans are eligible for auto wiring to another bean.
The annotation @Autowired in spring boot is used to auto-wire a bean into another bean.
it can be applied to a constructor, field, or setter method it helps to autowire the bean without creating an object using new keyword

@Component  
public class Customer  
{  
private Person person;  
@Autowired  
public Customer(Person person)   
{
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Spring Boot Actuator

A

It is a Spring library that used to manage and monitor production operations.
like endpoint URL mapping, beans, logging information, health check Matrics without we need to write too much code

To include Actuator in your Spring Boot project simply add it to the pom.xml
by default it is disable to make it active you have to do from application. Property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

@PathVariable:

A

It is used to extract the values from the URI path
it is used in method argument to bind it to the value of the URI templet variable
We can define multiple @PathVariable in a method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

@Configuration:

A

It is a class-level annotation. The class annotated with @Configuration used by Spring Containers as a source of bean definitions.

@Configuration  
public class Vehicle  
{  
@BeanVehicle engine()  
{  
return new Vehicle();  
}  
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

@ComponentScan:

A

It is used when we want to scan a package for beans.

We can also specify the base packages to scan.
@ComponentScan(basePackages = “com.javatpoint”)

It is used with the annotation @Configuration.

@ComponentScan
@Configuration  
public class ScanComponent  
{  
// ...  
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

@Component

A

It is a class-level annotation.
@Component is an annotation that allows Spring to automatically detect our custom beans.

It is used to mark a Java class as a bean. So you can Autowired
A Java class annotated with @Component is found during the classpath. 
The Spring Framework pick it up and configure it in the application context as a Spring Bean.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

@SpringBootApplication:

A

It is a combination of three annotations :
@EnableAutoConfiguration, (stop any configuration found in any other classes in the starter dependencies)
@ComponentScan, (scan all packages components(@Component, @Service, @Repository) inside the base package)
@SpringBootConfiguration (contain inside it @Configuration ) to provide a configuration as java base configuration

Types of configuration
1- xml configuration
2- java base configuration
3- Annotations configuration @Configuration

i.e we can create class configuration and add the @Configuration and @Bean to configure anything

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

@GetMapping:

A

It maps the HTTP GET requests on the specific handler method matched with given URI expression.

It is used to create a web service endpoint that fetches

Acts as a shortcut instead of using:
@RequestMapping(method = RequestMethod.GET)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

@PostMapping:

A

It maps the HTTP POST requests on the specific handler method.

It is used to create a web service endpoint that insert

It is used instead of using: @RequestMapping(method = RequestMethod.POST)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

@PutMapping:

A

It maps the HTTP PUT requests on the specific handler method.
It is used to create a web service endpoint that creates or updates

It is used instead of using: @RequestMapping(method = RequestMethod.PUT)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

@DeleteMapping:

A

It maps the HTTP DELETE requests on the specific handler method.
It is used to create a web service endpoint that deletes a resource.

It is used instead of using: @RequestMapping(method = RequestMethod.DELETE)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

@PatchMapping:

A

It maps the HTTP PATCH requests on the specific handler method.

It is used instead of using: @RequestMapping(method = RequestMethod.PATCH)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

@RequestBody:

A

It is used to bind HTTP request body with an object in a method parameter.

Internally it uses HTTP MessageConverters to convert the body of the request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

@ResponseBody:

A

It binds the method return value to the response body.

It tells the Spring Boot Framework to serialize a return an object into JSON and XML format.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

@RequestParam:

A

It is used to extract values from the query string URI after ?
(localhost:8080/employees?id=20)

It is also known as a query parameter.

It is most suitable for web applications.
It can specify default values if the query parameter is not present in the URL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

@RequestHeader:

A

It is used to get the details about the HTTP request headers.
We use this annotation as a method parameter.

The optional elements of the annotation are name, required, value, defaultValue.

For each detail in the header, we should specify separate annotations. We can use it multiple time in a method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

@RestController:

A

It is a combination of
@Controller
@ResponseBody

It ignore the need for annotating each method with @ResponseBody.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

@RequestAttribute:

A

It binds a method parameter to request attribute.
It provides convenient access to the request attributes from a controller method. With the help of @RequestAttribute annotation,
we can access objects that are populated on the server-side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

@AspectJ support

A

@AspectJ refers to a style of declaring aspects through the use of regular Java classes with annotations.
@AspectJ style was introduced in the AspectJ 5 release of the AspectJ Project. Note that Spring interprets the same annotations as AspectJ 5, using a library supplied by AspjectJ, however Spring’s AOP runtime is not dependent on the AspectJ compiler or weaver.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

@Transactional

A

JPA on itself does not provide any type of declarative transaction management.

When using Spring and Spring ORM or Spring Data your chosen ORM can be configured to use a transaction manager that will automatically handle transaction propagation, and isolation, commit, and rollback.

use the @Transaction annotation above the serviceimpl class so it will give the default configuration of transaction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

DevOps

A

Software Development (dev) Operations (ops)

Are a set of practices and methodologies use to combine the development, deployment and maintenance of code into a streamlined process.

The primary goal of DevOps is to accelerat the lifecycle of application development, particularly through the automation of tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

AOP Aspect Oriented Programming and Cross Cutting Concerns

A

Aspect-Oriented Programming supplements Object-Oriented Programming it is pattern to increase modularity. ( improves the quality of a specific piece of code.)
AOP breaks program logic into various parts, which are called cross-cutting concerns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What is cross-cutting concerns in Spring boot?

A

is a part of a program that rely on or must affect many other parts of the system

These cross-cutting concerns are different from the main business logic like Database, Security, data entities, error handling, Transaction Management. or logging system messages. so we can add additional behavior to the existing code without modification of the code itself just at runtime. it is reuse and you can Enable or disable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

@Aspect

A
@Aspect add to the class to become Aspect class with the @component 
It is a class that contains the pointcut expressions to match  the joinPoint methods 

@Around(“execution(com.demo.bookcrudbootresthibernate..(..))”)

A representation of a concern which cuts across multiple classes.

41
Q

How do you implement cross-cutting issues?

A

There are three approaches to implementing cross-cutting concerns:

1- Decorator pattern.
2- Aspect oriented programming and Interceptor pattern.
3- Dependency injection pattern.

42
Q

PointCut

A

A path of which methods in the application Advice going to be injected into

A pointcut is a predicate that help match an Advice to be applied by an Aspect at a particular JointPoint
(com.demo.bookcrudbootresthibernate..(..))

we often associaate the advice with a pointcut expression and it runs at any joinpoint match by the pointcut

After the advice we specify the pointcut expression or predicate to match the joinpoints

43
Q

@Around

A

When the Control Enter the Method and when leave the Method

@Around(“execution(com.demo.bookcrudbootresthibernate..(..))”)

@Around means before and after together

44
Q

Advice = action = when

A

Advice means (when) an action taken by an Aspect at a particular JoinPoint (Method in your code)

So Advise means (when) it ask when the method will executed –> before or after

@Around means before and after together

@Around, @Before, @After, @AfterThrowing, @AfterReturning all are Advices

45
Q

JoinPoint

A

It’s the actual method the executing in your code

46
Q

What is Spring Data

A

Spring Data is a high level Spring Source project allow us to access both relational database systems and NoSQL data stores. in the same way and eliminate duplicate of code to talk to entity manger

Spring Data is a high level Spring Source project which works together with JPA and provides a common abstraction that allow us to talk to different data store in the same way and eliminate duplicate of code to talk to entity manger

47
Q

Pom.xml

A

Pom is a XML file that contains information and configuration details used by Maven to build the project.

When executing a task or goal, Maven looks for the POM gets the needed configuration information, then executes the goal.

48
Q

What is meant by RESTful API?

A

REST stands for representational state transfer
REST is a client-service architecture that is based on a request/response design

Developers use RESTful APIs to perform requests and receive responses through HTTP functions.

49
Q

what is Lombok

A

instead to use setter and getter

is a Java library that can plug into editors to generate standardized code when defining Java classes (such as constructors, field getter and setter, equals and hashCode methods) at compile time throw annotations.

50
Q

what is ORM

A
ORM stand for Object Relational Mapping
Every table will map to a class call entity class same shape like pojo but with annotations
51
Q

What is the starter POMs do

A

It has all the dependencies so it helps you get a project up and running quickly

it has built-in
spring-boot-starter-tomcat,
spring-boot-starter-Json
spring-boot-starter-web

52
Q

What is the Auto Configuration

A

Auto-Configuration is decided based on
which framework is in the Classpath (Maven dependency folder) and
what is the existing configuration (Annotation added)

Auto Configuration = Application Context
Basic Configuration to run your application
using the framework defined in your
maven dependencies

when we start the application spring boot would look to all the classes which are available and base on the classes and configuration it auto configure a lot of things

53
Q

What is ResponseEntity Spring?

A

ResponseEntity represents the whole HTTP response: status code, headers, and body
While @ResponseBody puts the return value into the body of the response, ResponseEntity also allows us to add headers and status code.

we can control any options that goes into it

54
Q

What is URI

A

The request URI is the uniform resource identifier

55
Q

Spring boot Actuator

A

For Monitor and manage your application in your production

beans : Complete list of spring beans in your app
health : Application health information
metrics : Application metrics
mappings : Details around request mapping

It uses HTTP secured endpoints to enable us to interact with it.
Once this dependency is on the classpath, several endpoints are available for us out of the box

56
Q

Difference between URL and URI

A

URL (Uniform Resource Locator):
URL is a string of characters that not only identifies the resource located on the Internet but also gives the mechanism to reach the location and retrieve the data. Example: https://www.Amazon.com
URL components are protocol, domain, path, port, fragment, query string, etc.

URI (Uniform Resource Identifier):
URI is a string of characters that identifies a resource on the web by its name, address/location, or both. foo://example.com:8042/over/there?name=ferret#nose
URI components are scheme, authority, path, query, fragment, unique name etc

57
Q

What is Spring Boot Admin

A

Spring Boot Admin is a web application, used for managing and monitoring Spring Boot applications. Each application is considered as a client and registers to the admin server. Behind the scenes, the magic is given by the Spring Boot Actuator endpoints.

58
Q

What is CLI in spring boot?

A

The Spring Boot CLI is a Command Line Interface for Spring Boot. It can be used for a quick start with Spring. It can run Groovy scripts which means that a developer need not write boilerplate code; all that is needed is focus on business logic. Spring Boot CLI is the fastest way to create a Spring-based application.

59
Q

What is Thymeleaf In Spring Boot

A

Thymeleaf is a Java Template Engine which enables creation of web applications.
It enables interaction between Java Classes and HTML/XML templates.

60
Q

What Is Swagger?

A

Swagger™ is a framework used to describe and document RESTful APIs. The Swagger specification defines a set of files required to describe such an API

61
Q

What are the major differences between RequestMapping and GetMapping?

A

RequestMapping can be used with GET, POST, PUT, and many other request methods using the method attribute on the annotation.

GetMapping is only an extension of RequestMapping, which helps you to improve clarity on requests.

62
Q

What Are Profiles?

A

Profiles are used to separate various parts of your spring application configuration and make it only available for specific environments.

create more property files and add the “profile” name as the suffix and configure Spring Boot to pick the appropriate properties based on the profile.

we need to create three application.properties:
but the application.properties will remain as a master properties file

application-dev.properties
application-test.properties
application-prod.properties

We have used the @Profile(“Dev”) to let the system know that this is the BEAN that should be picked up
when we set the application profile to DEV. The other two beans will not be created at all.

One last setting is how to let the system know that this is DEV, TEST, or PROD. But, how do we do this?
We will use the application.properties to use the key below:
spring.profiles.active=dev

63
Q

What is LiveReload (hot swap)in Spring Boot?

A

LiveReload is a spring-boot-devtools module that includes LiveReload server to trigger a browser refresh when a resource is changed. LiveReload server extensions are available freeware for Firefox, Chrome, and Safari

64
Q

@Value

A

in the application.properties my.greetimg= Hello world

and in the controller class @Value(“${my.greeting }”)

or just incase if the my.creen is not exist we have a default value
@Value(“${my.greeting : default value}”)

65
Q

Externalized Configuration

A

Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments.
You can use properties files, YAML files, environment variables, and command-line arguments to externalize configuration.

$ java -jar myproject.jar –spring.config.name=myproject

$ java -jar myproject.jar –spring.config.location=classpath:/default.properties,classpath:/override.properties

66
Q

What do you mean by hot-swapping (LiveReload) in Spring Boot?

A

In web application developing, hot swapping means that you can modify the source code and see the changes immediately, simply by reloading the page in the web browser, without rebuilding your project and have to restart the web server.

67
Q

Auto-Configuration in Spring Boot.

A

Auto-configuration is used to configure Spring application automatically based on (jars) dependencies added in the classpath parameter. It makes development faster and easier.

68
Q

Explain caching

A

Storing frequently demanded things closer to those asking for it to increase the access speed

Caching is a part of temporary memory (RAM). It lies between the application and persistence database.
It stores the recently used data to reduces the number of database hits.
In other words, caching is to store data for future reference.

Types of data should be cached
The data that do not change frequently.
The frequently used read query in which results does not change in each call, at least for a period.

There are four types of caching are as follows:

In-memory Caching
Database Caching
Web server Caching
CDN Caching

69
Q

What is (CORS)

A

Cross-Origin Resource Sharing (CORS) is a security concept that allows restricting the resources implemented in web browsers.

It prevents the JavaScript code producing or consuming the requests against different origin. (domain, scheme, or port)

70
Q

Explain different types of dependency injection.

A

There are two types of dependency injection in Spring Boot. They are as follows:

•Constructor based dependency injection:
It is a technique in which one class object supplies the dependency of another object.
•Setter-based dependency injection:
It is a dependency injection in which the framework injects the primitive and string-based values using setter method.

71
Q

What is the default package in Spring Boot?

A

A class without any package declaration is considered as a default package.

72
Q

Explain the difference between an embedded container and a WAR.

A

Embedded containers help you to run Spring Boot application as a JAR from the command prompt without setting up any web server, while to run a WAR you need first to set up Tomcat.

73
Q

What is entity

A

To be able to store Point objects in the database using JPA we need to define an entity class.

Typically, an entity represents (map) a table in a relational database, and each entity instance corresponds to a row in that table.
the entity is a POJO (Plain Old Java Object) class but has @Entity annotation
74
Q

What is spring-boot-starter-parent?

A
75
Q

What is DevTools in Spring Boot?

A

Spring Boot DevTools helps you to increase the productivity of the developer. So, you don’t require to redeploy your application every time you make the changes. It allows the developer to reload changes without the need of restarting of the server.

76
Q

What is an API, and what is an Endpoint?

A

An API is a set of protocol and tools that allow two applications to communicate.

Endpoint is a URL that enables the API to access resources on a server, often through a RESTful API interface.
The Endpoint gives us the exact location of the service/resource that we wish to access

77
Q

What is the clsspath

A

It’s a path inside your project where you place resources.
During the build step, Maven will take files in there and place them in the appropriate place for you to use them in your runtime classpath, eg in an executable . jar , some physical file system location used in the classpath (with java ‘s -cp option), etc.

You can get the classpath that Maven used to compile your application with mvn dependency:build-classpath. That will print the classpath to the console. Note that it will be missing target/notification-1.0.0.jar.

78
Q

Object-Relational Mapping or ORM

A

Object-Relational Mapping or ORM is a technique for converting data between Java objects and relational databases.

79
Q

What is Spring WebFlux?

A

Spring WebFlux is a fully non-blocking, annotation-based web framework built on Project Reactor that makes it possible to build reactive applications on the HTTP layer

80
Q

What is @Bean wiring and @Autowired annotation?

A

@Bean tells Spring ‘here is an instance of this class, please keep hold of it and give it back to me when I ask’.

@Autowired says ‘please give me(inject) an instance of this class, that I already created an instance of it with an @Bean annotation earlier’.

@Bean is just for the metadata definition to create the bean
@Autowired is to inject the dependency into a bean

81
Q

What are different types of Spring Bean autowiring?

A

no ‘, ‘ byName ‘, ‘ byType ‘ and ‘ constructor ‘.

82
Q

What is a shutdown in the actuator?

A

Spring Boot provides some ready to use features to handle the lifecycle of Spring container including shutdown a Spring Boot application gracefully.

By default, all /shutdown endpoint is not enabled in the Actuator
To include and enable this, we need to add spring-boot-starter-actuator starter in our application pom.xml and require to enable /shutdown endpoint using application.properties or application.yml file.

83
Q

Docker in Spring Boot.

A

It is a tool designed to create, deploy, and run a project by using containers.

84
Q

@SLF4J

A

The SLF4J or the Simple Logging Façade for Java is an abstraction layer for various Java logging frameworks, like Log4j 2 or Logback. This allows for plugging different logging frameworks at deployment time without the need for code changes.

85
Q

What is the application context in Spring boot?

A

ApplicationContext is a corner stone of a Spring Boot application.
It represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the beans.

86
Q

What is spring-boot-starter-parent?

A

The spring-boot-starter-parent is a project starter.
It provides default configurations for our applications.
It is used internally by all dependencies.
All Spring Boot projects use spring-boot-starter-parent as a parent in pom.xml file

It is a special starter which makes Gradle or Maven dependency-management easy by adding jars to your classpath.

Parent allow you to manage things for multiple child project and module as
1- configuration -java version and other properties
2- Dependency management - version of dependencies will automatically added from parent
3- Default plugin configuration

87
Q

What is the use of @ComponentScan in Spring boot?

A

The @ComponentScan annotation is used to specify packages to locate components in Spring.
In the case of Spring Boot it is automatically done in the default package so we don’t need to add the annotation.
but if you use any component outside the default package you need to define @ComponentScan() to specify this component package and it will as

@ComponentScan( { “add the default package path”, “add the component package path” } )
@SpringBootApplication

88
Q

fetch =FetchType.EAGER

fetch =FetchType.LAZY

A

Eager load all relationship dependent entity (data) from all joins tables
(eg select * from user u join address a on a.u_id = u_id)
make the application performance load slow
————————————————–
Lazy load main entity only and then load the dependent entities on demand(when you need it) no joins to tables
(eg select * from user )
make the application performance load fast
reduces the memory for print on startup the program

89
Q

What does CascadeType.All mean?

cascade = CascadeType.ALL

A

is to add for @OneToMany relationship

Entity relationships often depend on the existence of another entity,
for example the Person–Address relationship. Without the Person, the Address entity doesn’t have any meaning of its own. When we delete the Person entity, our Address entity should also get deleted.
So cascade answers the question of what will happened when you delete e an object parent has a children’s reference objects

The meaning of CascadeType. ALL is that the persistence will propagate (cascade) all EntityManager operations ( PERSIST, REMOVE, REFRESH, MERGE, DETACH ) to the relating entities. It seems in your case to be a bad idea, as removing an Address would lead to removing the related person .

90
Q

What is the difference between DI and IOC?

A

Spring IoC Container is the core of Spring Framework.
It creates the objects,
configures and assembles their dependencies,
manages their entire life cycle.
The IoC Container uses Dependency Injection(DI) to manage the components that make up the application.

91
Q

How do you handle exceptions in spring boot globally?

A

In Java, exception handling is done by try, catch blocks but spring boot also allows us to provide customized global exception handling where we need not to add try catch block everwhere, we can create a separate class for handling exceptions and it also separates the exception handling code from businesss logic code.

92
Q

what does spring-boot-starter-web contains

A

Spring MVC, REST, JSON and Tomcat as a default embedded serve

93
Q

@ConfigurationProperties

A

it is like @Value but used to pull up a group of configuration properties at once from the Application properties under rules

1- configure this properties in the Application.properties as

mail. hostname=host@mail.com
mail. port=9000
mail. from=mailer@mail.com

2- map this configuration as instants variables in a class and 
@ConfigurationProperties(prefix = "mail")
@Configuration
@ConfigurationProperties(prefix = "mail")
public class ConfigProperties {
private String hostName;
private int port;
private String from;
    // standard getters and setters
}

3- in the controller layer you can @Autowire this bean and use the its properties

@Autowire
private ConfigProperties configProperties

94
Q

How Spring boot internally works or explain run() method

A

1- Spring boot application execution will start from main() method
2-The main() method internally call SpringApplication .run() method (run is a static method)
3- Spring Application.run() method performs bootstraping (load all necessary configuration and component required ) for run our spring boot aspplication.
4- Starts stopwatch to calculate time taken to bootstrap(start) the spring boot application
5- prepares/create environment object to our spring boot application (dev,prod, qa,uat)
6- print banner (spring Boot Logo prints on console)
7- start the IOC container (ApplicationContext) based on the classpath (web SERVLET or web REACTIVE or default)
8- Refresh application context
9- Stop Stopwatch
9- Call Runners (ApplicationRunner or CommandLineRunner)
10- The run() return ApplicationContext Reference (Spring IOC)

95
Q

Spring Boot Architecture

A

Spring Boot follows a layered architecture in which each layer communicates with the layer directly below or above (hierarchical structure) it.

Presentation Layer
Business Layer
Persistence Layer
Database Layer

96
Q

How many types of projects spring boot can create?

A
Spring-boot-starter
if we have this dependency in the classpath so this application come under default category and this create 
-Utilities Application 
-Stand alon Application
-Desktop Application GUI 

spring-boot-starter-web
if we have this dependency in the classpath so this application come under Servllet category and this create
-Spring MVC Application
-Spring MVC REST API Application

spring-boot-starter-webflux
if we have this dependency in the classpath so this application come under reactive category and this create
-Spring Boot Reactive Web Application

97
Q

What is Spring Batch

A

It is a lightweight batch framework based on spring used for high volume batch processing.
it has various I/O options like JSON, XML,SQL database
and easy to manage with start/stop/restart options
retry and skip mechanism

98
Q

YAML stand for

A

Yet Another Markup Language