Bonjour,
Je débute avec spring et en j2EE en général et je n'arrive pas à récupérer le XmlBeanFactory de mon fichier de configuration xml de spring.
le code nécessaire pour l'appel de mon fichier de config :
mon fichier de config :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 public class Servlet1 extends HttpServlet { private IService service = null; public void init() throws ServletException { // instanciation de la couche [service] avec spring ClassPathResource maRessource = new ClassPathResource("/WEB-INF/spring-config.xml"); service = (IService) new XmlBeanFactory(maRessource).getBean("service"); }
l'erreur que j'obtiens :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?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"> <!-- la classe dao --> <bean id="dao" class="PackageDAO.DaoImpl" init-method="init"/> <!-- la classe service --> <bean id="service" class="PackageService.ServiceImpl"> <property name="dao"> <ref local="dao" /> </property> </bean> </beans>
l'arborescence de mon projet en piece jointe.L'exception suivante s'est produite : IOException parsing XML document from class path resource [WEB-INF/spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/spring-config.xml] cannot be opened because it does not exist
J'ai essayer de mettre plusieurs chemin pour allez chercher la bean factory ou de mettre le fichier de configuration dans plusieurs dossiers mais rien y fait.
Need help![]()
Partager