Directly by using the constructors of the bean class.
Let’s take an example.
package com.jubilation.spring.user;
public class A {
public A() {
System.out.println(“Object of the class A is created…”);
}
}
Configuration will be like this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="a" class="com.jubilation.spring.user.A"/>
</beans>
Let’s take an example.
package com.jubilation.spring.user;
public class A {
public A() {
System.out.println(“Object of the class A is created…”);
}
}
Configuration will be like this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="a" class="com.jubilation.spring.user.A"/>
</beans>
Comments
Post a Comment