Springide Demo
Springide Demo
java
/**
*
*/
package com.vehicles;
/**
* @author Rajani Ramsagar
*
*/
public class Car {
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the cost
*/
public int getCost() {
return cost;
}
/**
* @param cost
* the cost to set
*/
public void setCost(int cost) {
this.cost = cost;
}
carDemo-beans.xml
carDemo-beans.xml
ShowRoom.java
/**
*
*/
package com.vehicles;
/**
* @author Rajani Ramsagar
*
*/
public class ShowRoom {
/**
* @return the mediumCars
*/
public Car getMediumCars() {
return mediumCars;
}
/**
* @param mediumCars
* the mediumCars to set
*/
public void setMediumCars(Car mediumCars) {
this.mediumCars = mediumCars;
}
/**
* @return the bigCars
*/
public Car getBigCars() {
return bigCars;
}
/**
* @param bigCars
* the bigCars to set
*/
public void setBigCars(Car bigCars) {
this.bigCars = bigCars;
}
carDemo-beans.xml
<?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">
SpringDemoApp.java
/**
*
*/
package com.vehicles;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
/**
* @author Rajani Ramsagar
*
*/
public class SpringDemoApp {
/**
* @param args
*/
public static void main(String[] args) {
BeanFactory beanFactory = new XmlBeanFactory(new
ClassPathResource(
"carDemo-beans.xml"));
log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC
"http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/log4j.dt
d"
"http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/log4j.dt
d">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<root>
<level value="info" />
<appender-ref ref="console" />
</root>
</log4j:configuration>