SpringBoot+Activiti 使用表达式无法注入dao

流程图:

 <activiti:taskListener event="create" expression="${test.t()}"></activiti:taskListener>

Test.class:

 package com.ponshine.service;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ponshine.dao.ActivitiDao;

@Service
public class Test{
    @Autowired
    ActivitiDao activitiDao;

    public void t(){
        System.out.println("--------------------");
        System.out.println(activitiDao.searchLastUserId("李四"));
    }
    public Test(){
        System.out.println("hello");
    }
}

activiti.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsdhttp://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
    <bean id="processEngineConfiguration"
        class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
        <property name="jdbcDriver" value="oracle.jdbc.driver.OracleDriver" />
        <property name="jdbcUrl" value="***" />
        <property name="jdbcUsername" value="activiti" />
        <property name="jdbcPassword" value="***" />
        <property name="databaseSchemaUpdate" value="true" />
        <property name="beans">
            <map>
                <entry key="test" value-ref="test"></entry>
            </map>
        </property>
    </bean>
    <bean id="test" class="com.ponshine.service.Test" ></bean>
</beans> 

结果:

    System.out.println(activitiDao.searchLastUserId("李四"));

这一行会报空指针。
打印activitiDao为空

你的activitiDao是不是要加 setter/getter方法