Cannot find the class file for org.springframework.context.ApplicationContextInitializer.
jdk是1.8,有沒有同學能幫下忙啊,搞了一天了,謝謝謝謝
第一個報錯:Description?? ?Resource?? ?Path?? ?Location?? ?Type
The project was not built since its build path is incomplete. Cannot find the class file for org.springframework.context.ApplicationContextInitializer. Fix the build path then try building this project?? ?seckill?? ??? ?Unknown?? ?Java Problem
第二個報錯:Description?? ?Resource?? ?Path?? ?Location?? ?Type
The type org.springframework.context.ApplicationContextInitializer cannot be resolved. It is indirectly referenced from required .class files?? ?SeckillDaoTest.java?? ?/seckill/src/test/java/org/seckill/dao?? ?line 1?? ?Java Problem
2019-10-11
換另一個版本的jar包就解決了。
2018-08-15
一樣的問題 重新下載了spring-context 搞定
2018-03-24
樓主,解決了嗎我也是這個問題
2017-07-31
如果加載不成功呢,可能就是包的問題,,,, 如果你的其他代碼寫的都對
2017-05-04
我和你一樣的問題,重新下載spring-context包就好了
2017-04-09
這是我的代碼:
package org.seckill.dao;
import static org.junit.Assert.*;
import java.util.Date;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.seckill.entity.Seckill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
?* 配置spring與junit的整合,junit啟動時加載spring容器
?*spring-test,junit
?*/
@RunWith(SpringJUnit4ClassRunner.class)
//告訴junit spring配置文件
@ContextConfiguration({"classpath:spring/spring-dao.xml"})
public class SeckillDaoTest {
//注入dao實現(xiàn)類依賴
@Autowired
private SeckillDao seckillDao;
@Test
public void testReduceNumber() {
Date killTime=new Date();
int updateCount=seckillDao.reduceNumber(1000L, killTime);
System.out.println("updateCount="+updateCount);
}
@Test
public void testQueryById() {
long id=1000;
Seckill seckill=seckillDao.queryById(id);
System.out.println(seckill.getName());
System.out.println(seckill);
/*
* 1000元秒殺iphone6
Seckill [seckillId=1000, name=1000元秒殺iphone6, number=100, startTime=Sun Nov 01 00:00:00 CST 2015, endTime=Mon Nov 02 00:00:00 CST 2015, createTime=Sat Apr 08 13:52:31 CST 2017]
*/
}
@Test
public void testQueryAll() {
//java沒有保存形參的記錄:queryAll(int offset,int limit)->queryAll(arg0,arg1)
List<Seckill>seckills=seckillDao.queryAll(0, 100);
for(Seckill seckill:seckills){
System.out.println(seckill);
}
/*
* Seckill [seckillId=1000, name=1000元秒殺iphone6, number=100, startTime=Sun Nov 01 00:00:00 CST 2015, endTime=Mon Nov 02 00:00:00 CST 2015, createTime=Sat Apr 08 13:52:31 CST 2017]
Seckill [seckillId=1001, name=500元秒殺ipad2, number=200, startTime=Sun Nov 01 00:00:00 CST 2015, endTime=Mon Nov 02 00:00:00 CST 2015, createTime=Sat Apr 08 13:52:31 CST 2017]
Seckill [seckillId=1002, name=300元秒殺小米4, number=300, startTime=Sun Nov 01 00:00:00 CST 2015, endTime=Mon Nov 02 00:00:00 CST 2015, createTime=Sat Apr 08 13:52:31 CST 2017]
Seckill [seckillId=1003, name=200元秒殺紅米note, number=400, startTime=Sun Nov 01 00:00:00 CST 2015, endTime=Mon Nov 02 00:00:00 CST 2015, createTime=Sat Apr 08 13:52:31 CST 2017]
*/
}
}
2017-04-09
不是你的代碼的問題啊同學,她的報錯信息顯示的是buildpath不完整,你去看看構建路徑唄。注釋了那句代碼就不報錯的話那就是你的導包錯誤了:是這個:import org.springframework.test.context.ContextConfiguration;
如果還不行的話其他配置文件要確定沒有錯,也有可能是你的maven下載jar包不正確,刪掉讓maven重下那個jar(springframework-test)可能就不會錯了。
2017-04-08
@ContextConfiguration({"classpath:spring/spring-dao.xml"}) 把這行代碼注釋掉就不報錯了,說明還是這加載錯了,但是不知道錯在哪,文件夾建錯了嗎???
2017-04-08
2017-04-08
要這樣寫的
@ContextConfiguration({"classpath:spring/spring-dao.xml"})
你的代碼沒有寫配置文件的路徑當然報錯