1

I have two projects and each project has Spring XML files in their respective resources folder.

But one project is referenced by the other projects like importing jar.

How can I use XML in jar?

nwinkler
  • 52,665
  • 21
  • 154
  • 168
verystrongjoe
  • 3,831
  • 9
  • 35
  • 66

2 Answers2

2

You can use classpath*:/application-context.xml - replace application-context.xml with your filename.

If your Spring XML file is named applicaiton-context.xml move it under a folder spring in both the projects. You can then create a context with both XML files like this

ApplicationContext ctx = new ClasspathXmlApplicationContext("classpath*:/spring/application-context.xml")
gkamal
  • 20,777
  • 4
  • 60
  • 57
  • Sorry, I can't understand what you mean. Can you make a example for that? – verystrongjoe May 10 '12 at 06:26
  • 1
    I have updated the answer based on guessing what your problem is. If it doesn't answer your question please consider editing your question to provide more information. – gkamal May 10 '12 at 06:52
0

You can use the xml from the jar and the xml from your project:

ApplicationContext context = new ClassPathXmlApplicationContext( new String[] {
                "classpath*:spring/applicationContext-*.xml"});

See my Question1 and Question2 here.

Community
  • 1
  • 1
blang
  • 2,090
  • 2
  • 18
  • 17