報錯訊息如下:
Error creating bean with name 'enum_Boolean' defined in file [C:\Users\yueho\eclipse-workspace\Mirrorworld\target\classes\com\stepforward\Mirrorworld\P2_Base_Bean\Enum_Boolean.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.stepforward.Mirrorworld.P2_Base_Bean.Enum_Boolean]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.stepforward.Mirrorworld.P2_Base_Bean.Enum_Boolean.()
有關的代碼如下:
@Component
public enum Enum_Boolean
{
True("Enum_Boolean","True","Yes","是"),
False("Enum_Boolean","False","No","否");
private String Enum_Name;
private String Id;
private String English;
private String Other_Language;
Enum_Boolean(){};
Enum_Boolean(String Enum_Name,String Id,String English,String Other_Language)
{
this.Enum_Name=Enum_Name;
this.Id=Id;
this.English=English;
this.Other_Language=Other_Language;
}
......
}
正在學習spring boot,請問:
1,好像這樣一個枚舉類bean,沒有依賴其他bean,需要注解嗎?如需要的話,上述注解問題在哪?應如何解決?
2,如不需注解,是否意味著不受spring管理?如不受spring管理,如有另外一個bean依賴此枚舉類bean,可以自動注入該枚舉類bean嗎?