我正在尝试设置一个 Spring 应用程序以第一次在 Eclipse 中运行。我将它作为独立的 java 应用程序运行。该应用程序构建时没有任何错误,但是当我去执行它时,我得到一个带有以下堆栈跟踪的 ClassNotFoundException:
DataLoadService [Java Application]
com.pikefin.services.DataLoadService at localhost:52871
Thread [main] (Suspended (exception ClassNotFoundException))
URLClassLoader$1.run() line: 217
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]
Launcher$AppClassLoader(URLClassLoader).findClass(String) line: 205
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: 321
Launcher$AppClassLoader.loadClass(String, boolean) line: 294
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 266
ClassPathXmlApplicationContext(AbstractApplicationContext).<init>(ApplicationContext) line: 161
ClassPathXmlApplicationContext(AbstractRefreshableApplicationContext).<init>(ApplicationContext) line: 90
ClassPathXmlApplicationContext(AbstractRefreshableConfigApplicationContext).<init>(ApplicationContext) line: 59
ClassPathXmlApplicationContext(AbstractXmlApplicationContext).<init>(ApplicationContext) line: 61
ClassPathXmlApplicationContext.<init>(String[], boolean, ApplicationContext) line: 136
ClassPathXmlApplicationContext.<init>(String) line: 83
DataLoadService.main(String[]) line: 20
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/java (Nov 6, 2012 1:14:23 PM)
它发生在这行代码上:
ApplicationContext context=new ClassPathXmlApplicationContext("classpath:spring.xml");
spring.xml 在构建过程中被移动到 class/ 文件夹中,所以我尝试将 class 文件夹添加到启动配置中(参见屏幕截图)。
我正在使用 eclipse 3.7.2 和 spring 3.1.1