Right path to applicationContext.xml using ClassPathXmlApplicationContext

后端 未结 5 1792
渐次进展
渐次进展 2021-02-03 13:03

I have working web-application with applicationContext.xml in WEB-INF/config/applicationContext.xml. Now i need to implement some testing tool as standalone application, that ca

5条回答
  •  一生所求
    2021-02-03 13:38

    In a local test scenario, you are not inside a Jar, so you don't need Classpath-based access. Use FileSystemXmlApplicationContext instead.

    Probably something like this:

    private static final ApplicationContext ac =
        new FileSystemXmlApplicationContext(
            "src/WEB-INF/config/applicationContext.xml"
        );
    

    (paths are relative from the execution directory)

提交回复
热议问题