报错
三月 07, 2017 8:09:52 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@41cf53f9: startup date [Tue Mar 07 20:09:52 CST 2017]; root of context hierarchy
三月 07, 2017 8:09:52 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'helloface' is expected to be of type [com.ij34.service.Hello] but was actually of type [com.sun.proxy.$Proxy7]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:378)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1082)
at com.ij34.bean.test.main(test.java:12)
package com.ij34.aspect; import org.aspectj.lang.annotation.*; @Aspect public class Autoaspect { @Before("execution(* com.ij34.service.*.*(..))") public void authority() { System.out.println("模拟执行权限检查"); } }
解决方法:去掉 .serivce
因为这路径还没有把com.ij34.inferfaces包含在内
或者把<aop:aspectj-autoproxy/> 修改成<aop:aspectj-autoproxy proxy-target-class="true"/>