java - How to access Spring context from a depending project? -


suppose have 2 projects:

projecta , projectb projecta depends on projectb 

and have context.xml locates @ projectb/target/test-classes/context.xml. need loat context projecta. in projectb have accesser class:

class contextaccessor{     applicationcontext context = new         classpathxmlapplicationcontext("context.xml");      public static applicationcontext getcontext(){         return context;     } } 

while in projecta, i'm trying context using:

contextaccessor.getcontext(); 

but throws exception message:

caused by: org.springframework.beans.factory.beandefinitionstoreexception: ioexception     parsing xml document class path resource [context.xml]; nested exception java.io.filenotfoundexception: class path resource [context.xml] cannot opened because not exist @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:341) @  

please give suggestions. appreciation.

you need make sure projectb (i suppose it's packaged jar) in projecta's classpath. refer here if using maven, understand how can done.

once it's in class path should able create context code given above. make sure location of context.xml correctly passed constructor, refer javadoc classpathxmlapplicationcontext.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -