package mundojava13.spring.gerenciador;
import java.util.Iterator;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
public class PrincipalComIoc {
public static void main(String[] args) {
BeanFactory factory = new XmlBeanFactory(new ClassPathResource(
"gerenciador.xml"));
GerenciadorEscolar gerenciador = (GerenciadorEscolar) factory
.getBean("gerenciador");
gerenciador.inserirCurso(new Curso("Jornalismo", "Comunicação Social"));
Iterator cursos = gerenciador.listarCursos().iterator();
while (cursos.hasNext()) {
System.out.println(cursos.next());
}
}
}
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [gerenciador.xml]; nested exception is java.io.FileNotFoundException: class path resource [gerenciador.xml] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [gerenciador.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:135)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at mundojava13.spring.gerenciador.PrincipalComIoc.main(PrincipalComIoc.java:12)
Valew! :thumbup: