Tuesday, May 7, 2019

Spring Boot

Spring boot Annotations
   https://javatechonline.com/spring-boot-annotations-with-examples/

Spring Boot Roadmap
   Spring Framework
        Core
           Bean Life cycle
           Dependency Injection
           IOC
           Bean Factory & application Context
        Web
            Annotations
            MVC Structure
            Configurations
            Integrating different Libraries/Framework
            Profiles    
        AOP 
            How Aspect Oriented Program (AOP) works
           Create Pointcut, Join Point, Aspect etc


    Spring Security
            Authentication
            Authorization
           OAuth2
            From Authentications
            JWT (token base authentication)

  Spring Boot
       Importance of Springboot
       Auto Configuration
       Adding Configuration
       Properties/YAML
       Integration with other Libraries/Frameworks
       REST API
            HTTP Methods
                    POST
                    GET
                    DELETE
                    OPTIONS
                    TRACE
            HTTP Status Codes
                     1.x.x
                     2.x.x
                     3.x.x    
                     4.x.x
                     5.x.x
     Database
            SQL
            NoSQL
            Spring Data
                   Spring Data JPA
                   Spring Data MongoDB (for MongoDB)
                   spring Data JDBC

    Microservices
                Spring Cloud
                    Spring Cloud Gateway
                    Spring Cloud Config
                    Spring Cloud Circuit Breaker
                    Spring cloud OpenFeign
                    Spring Cloud Sleuth
            
                Devops
                    Docker
                    Kubernetes
                    Cloud
                        AWS
                        GCP
                        Azure
                Microservices Pattern
                    Aggregator
                    CQRS
                    SAGA
                    Event Sourcing       

******************************************************************

Spring we have 
    BeanFactory
    ApplicationContext (ApplicationContext extends BeanFactory)


 Beans are configured using following options 
    XML
    Annotation
   Java configuration

Dependency Injection (DI) is achieved via following options 
Constructor Base
Setter base

What is Spring ?
      Application Framework
      Programming and Configuration Model
      Infrastructure Support


Spring Boot
  Opinionated
  Convention over configuration
  Stand alone

Starting Spring Boot
   Sets up default configuration
   Starts Spring application context
   Performs class path scan
   Starts Tomcat Server

Add a Controller 
    A Java Class
    Marked with annotations
    Has info about
        What URL access triggers it?
        What method to run when accessed?

   

GET -- > To fetch records
POST --> To insert a record
PUT --> To update a record
Delete --> to delete a record


Various ways to start spring Boot applictaion 
         Spring Initializr (http://start.spring.io)
         Spring Boot CLI (https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started-installing-spring-boot.html)
         STS IDE 


application.properties
   The file can be placed under src/main/resources directory. To know about various properties, use the below

https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html


Annotations
       For creating REST webservice below are the annotations used
             @RestController     --> To define a class to be a rest webservice
             @Autowired            --> To make sure what services are required for the class when it gets
                                                     initialized.
             @RequestMapping --> To form the URL so the Respt API can be accessed and it it can be
                                                     defined at class and method level
              @RequestBody       --> To read the body and it will be heavily used during POST and PUT
                                                      method
              @PathVariable        --> To map the query parameter variable with method parameter
                                                       variable

   For JPA below annotations are used
              @Entity              --> To mark a class corresponding to database table
              @Id                     -->  To mark a property as primary key corresponding to the column in
                                                   table
              @ManyToOne   --> To maintain many to one relationship between entities
              @ManyToMany --> To maintain many to many relationship between entities
              @ManytoAny    -->  To maintain many to any relationship between entities




Spring Data JPA (Java Persistence API)
    To interact with Relation database using Object- Relational Mapping (ORM).
    CRUD operations (Create Read Update Delete)


CrudRepository : Will have mostly used operations like Insert, Update , Delete and Select


Actuator : To monitor the spring boot application in prod.
https://spring.io/guides/gs/actuator-service/



*********************************************
Springboot 


@SpringBootApplication : is combination of the below three annotation
     @SpringBootConfiguration
     @EnableAutoConfiguration
     @ComponentScan
  

No comments:

Post a Comment