第一個dao空指針異常啊
java.lang.NullPointerException at org.seckill.dao.SeckillDaoTest.queryById(SeckillDaoTest.java:27) ?空指針啊,請問這是為什么,哪里沒注入嗎
java.lang.NullPointerException at org.seckill.dao.SeckillDaoTest.queryById(SeckillDaoTest.java:27) ?空指針啊,請問這是為什么,哪里沒注入嗎
2016-11-24
舉報
2017-12-07
為了便于今后人的查詢,我貼上我最終的解決方案:
原因導包錯誤
把包改成以下即可。
import org.junit.Test;
import org.junit.runner.RunWith;
import org.seckill.entity.Seckill;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import static org.junit.jupiter.api.Assertions.*;
2016-11-24
看你的測試的SeckillDao上面有沒有@Resource注解。
我調了整整兩天才發現。
框架就是難定位?。?/p>
希望幫到你!