2013-01-28 4 views
0

J'ai un projet Maven avec Spring. J'ai un projet backend comme jar dans le classpath (ajouté en tant que dépendance maven). Le projet backend est à nouveau avec Spring et possède son propre applicationContext.xml. Dans le projet frontend je applicationContext.xml et je veux accéder au contexte d'application de tha back-end comme celui-ci:Impossible de trouver applicationContext.xml à partir de jar dans classpath

<import resource="classpath:applicationContext.xml" /> 

mais je suis:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext.xml] 
Offending resource: ServletContext resource [/WEB-INF/appContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist 

essayé aussi:

<import resource="classpath*:applicationContext.xml" /> 

et

<import resource="classpath:/applicationContext.xml" /> 
+0

est-applicationContext.xml dans src/main/ressources? – Derek

+0

Oui. Dans le projet backend (pot) c'est là. Dans la FE (où je veux utiliser celui du pot) c'est dans WEB-INF –

Répondre

1

Si je comprends bien, vous voulez que le frontal accède au fichier applicationContext.xml du projet back-end. Classpath * est la bonne instruction, et vous devez vous assurer que les espaces de noms des deux fichiers de configuration sont les mêmes.

Par exemple, ce cas ne fonctionnera pas

frontal:

http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 

fin Retour:

http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
Questions connexes