Load Bean Definition From XML File : IoC Config « Spring « Java






Load Bean Definition From XML File

/*
Pro Spring
By Rob Harrop
Jan Machacek
ISBN: 1-59059-461-4
Publisher: Apress
*/



///////////////////////////////////////////////////////////////////////////////////////
//File: beans.xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    
    <!-- oracle bean used for a few examples -->
    <bean id="beanId" name="beanName" class="Bean"/>
    
</beans>




///////////////////////////////////////////////////////////////////////////////////////
public class Bean{

}


///////////////////////////////////////////////////////////////////////////////////////

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class XmlConfigWithBeanFactory {

    public static void main(String[] args) {
        XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(
                "build/beans.xml"));

    }
}


           
       








LoadBeanDefinitionFromXMLFile.zip( 1,197 k)

Related examples in the same category

1.Simplest Usage of property config file In Spring
2.IoC XML Config
3.Lookup Demo
4.IoC in properties file