Spring使用@Autowired包了空指针

####刚学spring,今天在写一个AOP的案例的时候,使用IOC注入包空指针异常,这是代码
我要在Service层中加入前置功能,但是使用 @Autowired注入的时候 personDaoImpl为空

@Service("personServiceImpl")
public class PersonServiceImpl implements PersonService {
    @Autowired
   private PersonDao personDaoImpl;

    @Override
    public void eat() {
        personDaoImpl.eat();
    }

    @Override
    public void sleep() {
        personDaoImpl.sleep();
    }

    @Override
    public void work() {
        personDaoImpl.work();
    }

    @Test
    public void show() {
        eat();
    }
}

这是dao

@Repository("personDaoImpl")
public class PersonDaoImpl implements PersonDao {

    @Override
    public void eat() {
        System.out.println("吃饭功能");
    }

    @Override
    public void sleep() {
        System.out.println("睡觉功能");
    }

    @Override
    public void work() {
        System.out.println("上班功能");
    }
}

这是配置文件

<?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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd"
>

    <context:component-scan base-package="com.zhang.*"></context:component-scan>



</beans>```


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/238435780046196.png "#left")

从上面代码没看出什么问题,能否把你使用PersonService的AOP代码贴出来,是否从spring应用上下文获取得PersonService?