我想設置一個Spring應用程序在eclipse中第一次運行。我正在運行它作爲一個獨立的Java應用程序。該應用程序構建沒有任何錯誤,但是當我去執行它,我得到以下堆棧跟蹤一個ClassNotFoundException:在Eclipse中彈簧類路徑問題
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得到在構建過程中移到類/文件夾中,所以我嘗試將類文件夾添加到啓動配置中(請參見截圖)。
我與Eclipse 3.7.2和3.1.1春季
你寫'ClassDefNotFound',但你的粘貼顯示'ClassNotFoundException'? –
Correcte。謝謝 – opike