Announcement Announcement Module
Collapse
No announcement yet.
Define enum as Spring Bean and dependency inject it into another Spring Bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:
    <bean id="myEnum" class="org.poc.MyEnum" >
    </bean>
    myEnum bean is not found.

    What am I missing?

  • #2
    1. You missed the forum - the question is not related to AOP at all;
    2. 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?

    Comment

    Working...
    X