Spring4无法执行Java8默认方法

Spring4无法执行Java8默认方法,spring,java-8,spring-4,Spring,Java 8,Spring 4,我已经定义了接口 public interface MyInterface { default void setOrder(int a){ } default int getOrder(){return 123;} } 和实施 public class MyInterfaceImpl implements MyInterface {} 在我的spring配置文件中,我定义了以下bean: <bean id="a" class="my.package.MyInterfac

我已经定义了接口

public interface MyInterface {
  default void setOrder(int a){ }
  default int getOrder(){return 123;}
}
和实施

public class MyInterfaceImpl implements MyInterface {}
在我的spring配置文件中,我定义了以下bean:

    <bean id="a" class="my.package.MyInterfaceImpl">
    <property name="order" value="999"/>
</bean>

我在4.1.6.0版本中使用spring。所以我的问题是为什么不可能从接口MyInterface执行方法setOrder,这是默认方法?spring似乎完全忽略了这些方法。

接口中默认方法的处理将随spring 4.2一起提供,因此在此之前,要么使用候选版本或里程碑,要么不使用spring的默认方法(或)

此问题仍然存在于spring 4.2.5.2版本中

我在Github上提供了一个示例:

并在这里用Spring记录了一张罚单:

我只能猜测一下,但是spring可能会通过设置一个值来检查方法,然后假设getter返回以前设置的值,将其返回。在你的例子中,这不会成功。尝试分配给某个字段或覆盖它们以测试此问题。请尝试将
更改为
,因为您的默认getter返回
123
而不是
999
。我刚刚升级到4.2.5.RELEASE,但仍然遇到此问题。此问题已得到修复,计划在2016年6月8日的Spring 4.3版本中包含
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?