我有一个构造函数采用Jakarta enums的类。我试图找到如何通过Spring XML aplicationContext 轻松注入它。
例如 :
枚举:
public class MyEnum extends org.apache.commons.lang.enums.Enum {
public static final MyEnum MY_FIRST_VALUE = new MyEnum("MyFirstValue");
public static final MyEnum MY_SECOND_VALUE = new MyEnum("MySecondValue");
public static MyEnum getEnum(String name) {
return (MyEnum) getEnum(MyEnum.class, name);
}
[...other standard enum methods]
}
注入的类:
public class MyService {
private final MyEnum status;
public MyService(MyEnum status) {
this.status = status;
}
}
应用程序上下文:
<bean id="myService" class="MyService">
<constructor-arg index="0" value="MyFirstValue" />
</bean>
当然,我有一个no matching editors or conversion strategy found
错误。Spring 和 Jakarta 枚举之间是否有简单的集成?还是我应该编写自己的 PropertyEditor ?