【Spring之旅】Spring学习常见问题汇总

来源:互联网 发布:易语言在线播放器源码 编辑:程序博客网 时间:2024/05/18 13:06

【Spring之旅】Spring学习常见问题汇总

1、【Spring bean的配置】

<!-- 定义代理类 -->
<bean id="proxyFactoryBeanID" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="proxyInterfaces" value="userBiz"></property>
    <property name="interceptorNames"><list><value>logBeforeAdvice</value></list></property>
    <property></property>
</bean>

在配置<property>标记,如果没有配置name属性,会报如下错误,原因是元素property必须有name属性,name属性指定Bean实例中的相应的属性名称,用于依赖注入。

cvc-complex-type.4: Attribute 'name' must appear on element 'property'.

2、【Spring AOP切面编程】

在使用spring 3.2.0做前置通知,LogBeforeAdvice 去实现MethodBeforeAdvice接口时报了如下错误:

第一处报了:The hierarchy of the type LogBeforeAdvice is inconsistent.

第二处报了:The type org.aopalliance.aop.Advice cannot be resolved. It is indirectly referenced from required .class files



解决方案:如果你写的类A 继承了 B 而B 继承 C,如果接口c或类C不在你所引的jar 包中,就报此信息,导入jar 包即可。
在此程序代码中则是MethodBeforeAdvice的父类不在org.springframework.aop中,需要将aopalliance-1.0.jar包导入到项目中即可。


---未完待续 

原创粉丝点击