package
com.springexample;
import
org.springframework.context.ApplicationContext;
org.springframework.context.support.ClassPathXmlApplicationContext;
public
class
RunMyProgram {
static
void
main(String[] args) {
ApplicationContext context =
new
ClassPathXmlApplicationContext(
"beans.xml"
);
StudentHolder studentHolder = (StudentHolder) context.getBean(
"studentHolder"
studentHolder.displayStudentDetails();
}
StudentHolder {
Student student;
Student getStudent() {
return
student;
setStudent(Student student) {
this
.student = student;
displayStudentDetails(){
System.out.println(
"Student Details"
"---------------"
"Student No: "
+student.getStudentNo());
"Student Name: "
+student.getStudentName());
<?
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-3.0.xsd"
>
bean
id
"student"
"com.springexample.Student"
property
name
"studentNo"
value
"1001"
/>
"studentName"
"John Peter"
</
"com.springexample.StudentHolder"
"#{student}"
Student {
private
int
studentNo;
String studentName;
getStudentNo() {
setStudentNo(
studentNo) {
.studentNo = studentNo;
String getStudentName() {
studentName;
setStudentName(String studentName) {
.studentName = studentName;
Do you want to delete a "" lesson. Warning! This delete will remove all it's sub lessons and contents.
Do you want to delete a "" sub lesson. Warning! This delete will remove all it's contents.
Do you want to delete content.
Do you want to remove selected book from favorite books.
Do you want to delete selected author from your authors list.