我有一个静态主指向应用程序上下文文件。在项目成为maven项目之前,我在Netbeans的“”(即根目录)中保留了“applicationContex.xml”。现在,当我运行我的代码时,显示错误。最新Mavenized项目 - 找不到类路径
有人能告诉我我的应用程序上下文文件的正确位置吗?
@Service
public class TestDriver {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
错误:
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
Directory of C:\NetBeansProjects\prj\trunk\src\main\java
8/15/2012 09:38 AM <DIR> .
8/15/2012 08:58 AM <DIR> ..
8/15/2012 09:38 AM 162 jcbc.properties
8/15/2012 09:38 AM 879 log4j.properties
8/15/2012 09:38 AM 1,691 applicationContext.xml
3 File(s) 2,732 bytes
这是非常有帮助的。你知道我应该把jdbc.properties放在哪里吗?我把它放在资源目录中,但它没有在那里看到它。 – EdgeCase 2012-08-15 15:42:14
src/main/config似乎是jdbc.properties的地方。 http://stackoverflow.com/questions/2525028/referencing-a-file-via-classpath-in-spring-context?lq=1 – 2012-08-15 16:27:15
@BuckTurgidson做到了这一点? – 2012-08-16 17:20:23