dimanche 12 avril 2015

Some doubts about the use of the preix in the Spring ApplicationContext creation, how exactly works?

I am studying for the Spring Core certification and I have a doubt related about how correctly declare a new FileSystemXmlApplicationContext into a Spring 4 application.


I know that, into my main() method I could have something like this:



ApplicationContext context = new FileSystemXmlApplicationContext("classpath:mycompany.mydivision.myapplication.application.config.xml", "file:test-infra-config.xml");


So, correct me if I am sayng wrong assertion, this line create the Spring Application Context (the object from which I will get my bean) from 2 differents files that contains the beans definitions for my app, respectivelly named config.xml and test-infra-config.xml.


My doubts are: what exactly means that the first one is taken from the classpath and the second one from the file?


I think that the second one path is relative to the the JVM working directory and the first one from the application classpath (definied in the project, or what?)


My doubts are: in Spring 4 are the use of the classpath: and of the file: prefix mandatory?


From what I have understand I can omit the file: prefix but not the classpath: prefix (but I am not sure if it is true in the Spring 3 version or if it is changing something in the 4 version). If it is true why I can omit the file: prefix but not the classpath: prefix?


Tnx


Aucun commentaire:

Enregistrer un commentaire