
hai I have design a simple application in this I always found class not found exception. I am sendig code as follows please resolve this and send me.my directory structure is as follows
Project:Student/src/com.mazeed/StudentComponet.java/TestClient.java/springConfig.xml for this I have added lib files also
StudentComponent.java:
package com.mazeed;
public class StudentComponent {
private String sname;
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
private String fname;
private String city;
public StudentComponent() {
}
}
TestClient.java
package com.mazeed;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.*;
public class TestClient {
public static void main(String[] args)
{
Resource res=new ClassPathResource("springConfig.xml");
BeanFactory container=new XmlBeanFactory(res);
System.out.println("container created");
Object o=container.getBean("studbean");
StudentComponent sc=(StudentComponent)o;
System.out.println(sc.getCity());
System.out.println(sc.getFname());
System.out.println(sc.getSname());
}
}
Beans configuration:
<?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-2.5.xsd">
<bean id="studbean" class="StudentComponent"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="sname">
<value>mazeed</value></property>
<property name="fname">
<value>Raheem</value>
</property>
<property name="city">
<value>Hyderabad</value>
</property>