Spring Boot - MicroServices - Ineuron - Ai
Spring Boot - MicroServices - Ineuron - Ai
Part 02:
Spring Boot CLI – This allows you to Groovy / Maven for writing Spring
boot application and avoids boilerplate code.
Starter Dependency – With the help of this feature, Spring Boot aggregates
common dependencies together and eventually improves productivity and
reduces the burden on
Spring Initializer – This is a web application that helps a developer in
creating an internal project structure. The developer does not have to
manually set up the structure of the project while making use of this feature.
Auto-Configuration – This helps in loading the default configurations
according to the project you are working on. In this way, unnecessary WAR
files can be avoided.
Spring Actuator – Spring boot uses actuator to provide “Management
EndPoints” which helps the developer in going through the Application
Internals, Metrics etc.
Logging and Security – This ensures that all the applications made using
Spring Boot are properly secured without any hassle.
This enables the developer to use a single annotation instead of using multiple
annotations thus lessening the lines of code. However, Spring provides loosely
coupled features which is why we can use these annotations as per our project
needs.
45. What are the effects of running Spring Boot Application as “Java
Application”?
The application automatically launches the tomcat server as soon as it sees that
we are running a web application.
Spring Boot allows the developers to run the same application in different
environments by making use of its feature of external configuration.
This uses environment variables, properties files, command-line arguments,
YAML files, and system properties to mention the required configuration
properties for its corresponding environments.
49. Can you tell how to exclude any package without using the
basePackages filter?
We can use the exclude attribute while using the annotation
@SpringBootApplication as follows:
@SpringBootApplication(exclude= {Student.class})
public class MainAppConfiguration {
51.Can the default web server in the Spring Boot application be disabled?
@RequestMapping:
This provides the routing information and informs Spring that any HTTP
request matching the URL must be mapped to the respective method.
org.springframework.web.bind.annotation.RequestMapping has to be imported
to use this annotation.
@RestController:
This is applied to a class to mark it as a request handler thereby creating
RESTful web services using Spring MVC. This annotation adds the
@ResponseBody and @Controller annotation to the class.
org.springframework.web.bind.annotation.RestController has to be imported to
use this annotation.
RequestMapping can be used with GET, POST, PUT, and many other request
methods using the method attribute on the annotation.
Whereas GetMapping is only an extension of RequestMapping which helps you
to improve on clarity on request.
59. What are the actuator-provided endpoints used for monitoring the
Spring boot application?
60. How to get the list of all the beans in your Spring boot application?
Spring Boot actuator “/Beans” is used to get the list of all the spring beans in
your application.
Spring Boot actuator “/env” returns the list of all the environment properties of
running the spring boot application.
You can define both application and Spring boot-related properties into a file
called application.properties.
You can create this file manually or use Spring Initializer to create this file.
You don’t need to do any special configuration to instruct Spring Boot to load
this file, If it exists in classpath then spring boot automatically loads it and
configure itself and the application code accordingly.
64. Mention the minimum requirements for a Spring boot System.
Maven 3.3+
Gradle 4.4+
JPA
JPA is a Data Access Abstraction used to reduce the amount of boilerplate
code.
Hibernate
Hibernate is an implementation of Java Persistence API and offers
benefits of loose coupling.
68. What are the differences between @SpringBootApplication and
@EnableAutoConfiguration annotation?
@SpringBootApplication
Used in the main class or bootstrap class.
It is a combination of @Configuration, @ComponentScan and
@EnableAutoConfiguration annotations.
@EnableAutoConfiguration
Used to enable auto-configuration and component scanning in your
project
It is a combination of @Configuration and @ComponentScan
annotations
69. How is Hibernate chosen as the default implementation for JPA without
any configuration?
When we use the Spring Boot Auto Configuration, automatically the spring-
boot-starter-data-jpa dependency gets added to the pom.xml file.
Now, since this dependency has a transitive dependency on JPA and Hibernate,
Spring Boot automatically auto-configures Hibernate as the default
implementation for JPA, whenever it sees Hibernate in the classpath.
Since Spring Boot supports Log4j2 for logging a configuration, you have to
exclude Logback and include Log4j2 for logging.
This can be only done if you are using the starters project.
Spring Boot has many starters. They are a set of convenient dependency
descriptors. Starter allows you to include these descriptors in your pom.xml.
For example, If you want to work with Spring MVC, you can include “spring–
boot–starter–web” as a dependency in pom.xml.
74. Can you use Spring Boot with applications which are not using Spring?
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. How can you access a value defined in the application? What is
properties file in Spring Boot?
Use the @Value annotation to access the properties which is defined in the
application .properties file.
@Value("${custom.name}")
private String customName;
77.Explain Spring Boot Admin?
Spring Boot admin is a community project which helps you to manage and
monitor your Spring Boot applications.
Dev
QA
Stage
Production
To be continued………..