IOException analyse le document XML à partir de la ressource de chemin de classe
Ok je suis en train d'essayer mavenise un projet. Cependant, mon projet ne parvient pas à trouver le fichier xml contenant les quelques haricots. combined2.xml
Je l'ai défini comme:
public RepeatingGrpPoC() {
appContext = new ClassPathXmlApplicationContext(
new String[] { "src/main/java/resources/combined2.xml",});
c = 0;
}
Cependant, pour une raison inconnu pour moi, j'ai toujours l'erreur.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [src/main/java/resources/combined2.xml]; nested exception is java.io.FileNotFoundException: class path resource [src/main/java/resources/combined2.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at metadataPoC.RepeatingGrpPoC.<init>(RepeatingGrpPoC.java:34)
at metadataPoC.Main.main(Main.java:22)
Causés par: java.io.FileNotFoundException: le chemin de classe de ressource [src/main/java/resources/combined2.xml] ne peut pas être ouvert car il n'existe pas
au org.springframework.de base.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
au org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... Plus de 14
Où d'autre pourrait le programme de recherche de ce fichier depuis, je lui ai donné le chemin relatif?
source d'informationauteur Will | 2011-05-09
Vous devez vous connecter pour publier un commentaire.
Il est en train de charger ce fichier dans le chemin de classe et ne peut pas le trouver. Essayez de spécifier juste
"combined2.xml"
au lieu de"src/main/java/resources/combined2.xml"
et assurez-vous que le répertoire src/main/java/ressources sur votre classpath.Par la façon dont, dans Maven, le répertoire standard pour les ressources est
src/main/resources
donc je vous suggère de placer ce fichier là.Maven, a de répertoire standard pour les ressources est qui est src/main/resources, donc, si vous gardez votre fichier ici, il va le prendre.
et dans le chemin de simplement donner le nom de fichier.
Par exemple
J'ai eu le même problème, il a travaillé pour moi
Essayer cette