SBMS 6am 24112022
SBMS 6am 24112022
SBMS 6am 24112022
=====================================================================
1. To create object
<bean id="objName" class="FullQualifiedClassName"> </bean>
</property>
===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>
<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>
GroupId : com.app.raghu
ArtifactId: SpringCoreFirstApp
Version : 1.0
> Finish
<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