星辰_mya 2018-06-15 03:57 采纳率: 50%
浏览 5384
已结题

springboot项目controller注入失败,空指针;单元测试没有问题

controller调用service、service调用dao 均报空指针问题

@Controller
public class TimeoutController extends AbstractController {

    @Autowired
    private LaoLuShiTangSkill laoLuShiTangSkill;

接口

 public interface LaoLuShiTangSkill {

service实现

import org.springframework.stereotype.Service;
 @Service
public class LaoLuShiTangSkillImpl implements LaoLuShiTangSkill {

    @Autowired
    private UserBehaviorRecordDao userBehaviorDao;
    @Autowired
    private SkillUseRecordDao skillUseRecordDao;
    @Autowired
    private LaoLuShiTangContentDao laoLuShiTangContentDao;

mapper

import org.apache.ibatis.annotations.Mapper;
 @Mapper
public interface UserBehaviorRecordDao {
  • 写回答

12条回答

  • ZhangDaniel_ZD 2018-06-15 03:58
    关注

    /**

    • @author jins
    • @date on 2018/5/6.
      */

      @RunWith(SpringJUnit4ClassRunner.class)

      public class RedisTest {

      @Autowired

      private StringRedisTemplate stringRedisTemplate;

      @Test

      public void redisTest(){

      stringRedisTemplate.opsForValue().set("ceshi","redis");

      System.out.println(stringRedisTemplate.opsForValue().get("ceshi"));

      }

      }

    评论

报告相同问题?

悬赏问题

  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题