2017-07-22 6 views
1

Ich habe eine Spring-Datasource.xml-Datei im/WEB-INF-Pfad. Ich möchte es in AppConfig.java importieren, dass es eine Konfigurationsdatei ist. Was ist der korrekte Pfad in @ImportResource in der NetBeans IDE? Ich kodiere im Frühling MVC. Ich weiß, dass ich folgendes verwenden sollte:@ImportResource-Pfad im Frühjahr MVC

@ImportResource(classpath:Spring-Datasource.xml) 

Aber es funktioniert nicht. Projekt Hirearchy:

-FinalWebStore 
    -Web Pages 
    -WEB-INF 
      +views 
      web.xml 
      mvc-dispatcher-servlet.xml 
      Spring-Datasource.xml 
    -Source Packages 
     +com.karans.finalwebstore.controllers 
     +com.karans.finalwebstore.daoimps 
     +com.karans.finalwebstore.daos 
     +com.karans.finalwebstore.models 
    +Dependecies 
... 

Antwort

1

WEB-INF Verzeichnispfad ist in Classpath in einem Frühling project.Move die Datei in src/main/resources und importieren Sie es nicht zur Verfügung wie folgt:

@ImportResource(classpath:Spring-Datasource.xml) 
+0

Was ist genau Classpath? – ma98

0

es Classpath ist src/main/resources und wenn Ihre Datei dort ist, dann wird Recht sein @ImportResource("classpath:SpringDatasource.xml")