本文主要是介绍Spring3.1异常处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
异常一:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationService' defined in file [D:\developeProject\myeclipseTest\DBCenter\WebRoot\WEB-INF\classes\com\meta\dbcenter\application\service\impl\ApplicationServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: id [Xlint:invalidAbsoluteTypeName]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
原因1:
@Pointcut(value="execution(public * com.meta.dbcenter.application.service.impl.ApplicationServiceImpl.getApplicationById(*))")
public void doGetApplication(){}
@Before("doGetApplication(id)")
public void beforeGetMethod(){
System.out.println("beforeGetMethod()");
}
原因2:
@Pointcut(value="execution(public * com.meta.dbcenter.application.service.impl.ApplicationServiceImpl.getApplicationById(*))")
public void doGetApplication(String id){ // 不需要string id}
@Before("doGetApplication(id)") // 不需要id
public void beforeGetMethod(){
System.out.println("beforeGetMethod()");
}
Multiple annotations found at this line:
- Pointcut is malformed: warning no match for this type name: id [Xlint:invalidAbsoluteTypeName]
- Pointcut is malformed: Pointcut is not well-formed: expecting '(' at character position 0 doGetApplication ^
- Pointcut is malformed: Pointcut is not well-formed: expecting ')' at character position 92 execution(public *
com.meta.dbcenter.application.service.impl.ApplicationServiceImpl.get*(*)&&(id)) ^^
原因1:
@Pointcut(value="execution(public * com.meta.dbcenter.application.service.impl.ApplicationServiceImpl.getApplicationById(*))&&args(id)") //使用args(id)不当
}
异常三:
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'applicationService' must be of type [com.meta.dbcenter.application.service.impl.ApplicationServiceImpl], but was actually of type [com.sun.proxy.$Proxy7]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
原因1:
使用了jdk的自动动态代理,需要在<aop:aspectj-autoproxy中添加proxy-target-class="true" 如下:
<aop:aspectj-autoproxy proxy-target-class="true"/>
这篇关于Spring3.1异常处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!