Date : 15-09-2022
Spring Boot and Microservices
Mr. Raghu
(ASHOK IT)
------------------------------------------------------------------
@Component @Value @ComponentScan
@Autowired @Scope
@Configuration @Bean @PropertySource
AshokIT Admin : +91 630 192 1083
9985 29 6677
9986 39 6677
Email: javabyraghu@[Link]
Spring Boot:-
1. AutoConfiguration (Pre-defined configuration code -- Java Config)
2. No XML Configuration supported
3. Frontend (Angular/ReactJS) + Backend (Spring Boot)
Spring Boot ReST Webservices + Microservices/Spring Cloud
** Spring Cloud:(Coding) To Develop application using Microservices
** AWS Cloud :(Run) To Deploy application
** Spring boot supports even MVC (Model - View [JSP/Thyemeleaf] - Controller)
Model - Data
View - Display / UI/UX
Controller - class/request processing code
4. Tools : maven - [Link] / gradle - [Link]
5. Embedded Servers - Tomcat**, Jetty and Undertow
6. Embedded Databases - H2, HSQL, Derby (Test/Dev Env)
7. Packing/ build models - .jar / .war
8. Parent Project (spring-boot-starter-parent) exist for
every spring boot application.
It takes care of versions of dependecies.
*) JAR : Java Archive ( .class files )
[Link] , [Link] --> compile --> [Link] [Link] --build-> [Link]
WAR : Web Archive ( .class + HTML/CSS/JS...)
(Used for web applications)
9. Maven Plugins: That gives additional task/works can be executed
Compiler plugin -- Supports updating JDK/JRE version
Build Plugin -- Supports converting jar/war
===============================================================
Spring Boot Application Files:
1. Starter class:
This one creates spring container (ApplicationContext)
with all required objects and setup.
It is a simple main() class.
The actual logic is present in : [Link]() method
2. Input file : key=val pairs
=> This is used to provide key:val pairs as input to Spring container
1. [Link]
[Link]=9898
2. [Link]
server:
port: 9898
*) We can add two types of keys,
Pre-defined and programmer-defined/user defined
Pre-defined keys Ref Link:
[Link]
[Link]#[Link]
3. Build File
-> Parent Project Details
-> Our Project Details
-> Properties (Java version, Spring cloud version..etc)
-> Dependencies (Jars)
-> plugins (Compiler, Build, SonarQube , JACOCO..etc)
==============================================================
Required S/w
JDK : 17/11
[Link]
STS : Spring Tool Suite
> Download and double click to Extract
[Link]
===============First Application Steps =======================
1. File > new > Spring Starter Project
2. Provide details
Name : SpringBootFirstApp
Version : 1.0
package : [Link]
3. Next > select Dependencies (Spring web) > next > finish
*) When we click on finish button STS makes request to
[Link] website that gives spring boot
application with setup
Example Req:
[Link]
name=firstapp
& groupId=[Link]
& artifactId=firstapp
& version=1.0
& description=Demo+project+for+Spring+Boot
& packageName=[Link]
& type=maven-project
& packaging=jar
& javaVersion=17
& language=java
& bootVersion=2.7.3
===Test application=====================
1. Create one new application
2. Choose Dependency : Spring web
3. [Link]
[Link]=9696
4. Open Main class > Right click > Run as > Spring Boot application
5. Goto Browser and enter URL
[Link]