Spring 常见错误
1.getBean的class类放错了
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named
'accountDao2' is expected to be of type 'com.zhw.dao.impl.AccountDaoImpl2'
but was actually of type 'com.sun.proxy.$Proxy14'
如果改成它的接口就不会报错了
2.忘记加AspectJ包了
警告: Exception encountered during context initialization - cancelling refresh
attempt: org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'org.springframework.context.event.internalEventListenerProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0':
Cannot resolve reference to bean 'serviceOperation' while setting bean property
'pointcut'; nested exception is org.springframework.beans.factory.
BeanCreationException: Error creating bean with name 'serviceOperation':
Failed to introspect bean class [org.springframework.aop.aspectj.
AspectJExpressionPointcut] for lookup method metadata: could not find class
that it depends on; nested exception is java.lang.NoClassDefFoundError:
org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
上面一大段不要被它吓到了,直接看最后两行就好了
that it depends on; nested exception is java.lang.NoClassDefFoundError:
org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
没有找到包!
3.没有打开mysql服务了
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver
has not received any packets from the server.
打开mysql服务
再次运行