Ada*_*wka 8 spring java-8 spring-4
我已定义界面
public interface MyInterface {
default void setOrder(int a){ }
default int getOrder(){return 123;}
}
Run Code Online (Sandbox Code Playgroud)
和实施
public class MyInterfaceImpl implements MyInterface {}
Run Code Online (Sandbox Code Playgroud)
在我的spring配置文件中,我定义了以下bean:
<bean id="a" class="my.package.MyInterfaceImpl">
<property name="order" value="999"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
当我创建spring上下文时,我遇到以下错误:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'order' of bean class [my.package.MyInterfaceImpl]: Bean property 'order' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Run Code Online (Sandbox Code Playgroud)
我在版本4.1.6.RELEASE中使用spring.所以我的问题是为什么不可能从接口MyInterface执行默认方法setOrder?看来春天完全忽略了这样的方法.
接口中的默认方法的处理将在Spring 4.2中提供,因此在此之前要么使用候选版本或里程碑,要么不使用Spring的默认方法(https://jira.spring.io/browse/SPR-12822或https: //jira.spring.io/browse/SPR-10919)
归档时间: |
|
查看次数: |
969 次 |
最近记录: |