Back Forum Reply New

Define enum as Spring Bean and dependency inject it into another Spring Bean

I am getting exception when I define an enum class as a Spring bean.Code:
package org.poc;

public enum MyEnum {
VAL1,
VAL2;
}
My XML snippet of code:

Code:
lt;bean id=quot;myEnumquot; class=quot;org.poc.MyEnumquot; gt;
lt;/beangt;
myEnum bean is not found.

What am I missing?

You missed the forum - the question is not related to AOP at all;
Your config declares a new instance of class 'org.poc.MyEnum' that should be instantiated using no-args constructor. It's perfectly expected that such a config fails;

Regarding solution - is it really necessary for you to have that 'Class' object defined as a separate bean? Isn't it better to directly define it as a target bean property?
¥
Back Forum Reply New