SBMS 6am 24112022

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Date : 24-11-2022

Spring Boot and Microservices


6AM | Mr. Raghu | (ASHOK IT)
---------------------------------------------------------------------
javabyraghu@gmail.com

Chapter#1 Spring Core

*) Simple Spring Core First Application.


1. Spring Bean
=> Simple Java class that follows rules given by Container
2. Spring Configuration File(XML)
=> It gives object details (name, data, links with other objects ..etc)
3. Test class
=> Just find, container created or not? Object is created or not?
===Spring Core XML Tags============================================
<bean> - Object creation

<property> -- calling set method


<constructor-arg> -- call parameterized constrcutor

<value> ---- To provide data to Primitive Type.


<list> <set> <map> <props> -- To provide data to collection type

<ref/> --- To link two objects

=====================================================================
1. To create object
<bean id="objName" class="FullQualifiedClassName"> </bean>

2. To call set method


<property name="variableName">

</property>

3. To provide data to Primitive Variable.


<value> SOME DATA </value>

===Example==============================================================
1. Spring Bean
package com.app.raghu;
public class PaymentService {
private int token;
private boolean active;
private String provider;
//set,get..toString..
}
2. Spring XML Configuration Code
<bean class="com.app.raghu.PaymentService" id="psObj">
<property name="token">
<value>115623</value>
</property>
<property name="active">
<value>true</value>
</property>
<property name="provider">
<value>ICICIB</value>
</property>
</bean>
*) value as attribute:
<bean class="com.app.raghu.PaymentService" id="psObj">
<property name="token" value="115623" />
<property name="active" value="true" />
<property name="provider" value="ICICIB" />
</bean>

--------Equal Java code -------


<bean class="com.app.raghu.PaymentService" id="psObj">
is equals to:
PaymentService psObj = new PaymentService();

<property name="provider">
<value>ICICIB</value>
</property>
is equals to:
psObj.setProvider("ICICIB");

*)Note:
1. XML is case-sensitive, <bean> and <BEAN> are different.
2. Every tag must have closing tag or self closed.

<property name="provider">
<value>ABC</value>
</property>

<property name="provider" value="ABC" />


========================================================================
************************************************************************
Create Maven Project with below steps:
************************************************************************
========================================================================
1. Create Project
> File > new > other > Type Maven > Choose Maven Project > next
> Choose Checkbox [v] Create Simple Project > Next > Enter details

GroupId : com.app.raghu
ArtifactId: SpringCoreFirstApp
Version : 1.0

> Finish

2. pom.xml [POM-Project Object Model]


(Paste below code after version tag and before project close tag)

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.23</version>
</dependency>
</dependencies>
3. Update Maven Project (alt+F5)
> Right click Project > Maven > Update Project > Choose Check box
[v] Force Update > Finish

======================STS/Eclipse Key Shortcuts=====================


ctrl + / ctrl - : To adjust font sizes

ctrl + shift + F : To do Indentation

Alt+F5 : To update Maven Project

ctrl+shift+T : To open any pre-defined java class

ctrl+O : View all members of class

ctrl+L : Goto Line Number


======================================================================

You might also like