• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

configuration location not identify in @ContextConfiguration

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have place the configuration file for spring beans in package,
main.resources.com.springsample

But when i try to load it with below, the file couldn't identified. It always take the path where the current test class reside (different package from where xml file reside)



Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [test/com/springsample//main/resources/com/springsample/springsample-introductions.xml]; nested exception is java.io.FileNotFoundException: class path resource [test/com/springsample//main/resources/com/springsample/springsample-introductions.xml] cannot be opened because it does not exist

But when i try without annotation like below, it recognized the file successfully,
ApplicationContext context =
new ClassPathXmlApplicationContext("\\main\\resources\\com\\springsample\\springsample-introductions.xml");



 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best practice says test cases should have their own configuration. This way you can define only the beans needed by the test case and you keep production configuration separate from test configuration. You should put these in src/test/resources not src/main/resources/

I assume this is for a test case as that is what @ContextConfiguration is used for.

That said my next suggesting is stop using \ and start using / that way you don't have to escape them.

Start on the root of the classpath and try


or alternatively


 
reply
    Bookmark Topic Watch Topic
  • New Topic