Creating a Spring enum bean and passing the value of a method call

后端 未结 1 1478
独厮守ぢ
独厮守ぢ 2021-02-19 01:01

I have this Singleton:

   public enum Elvis {
       INSTANCE;
       private int age;

       public int getAge() {
           return age;
       }
   }
         


        
相关标签:
1条回答
  • 2021-02-19 01:19

    You can use Spring Expression Language:

    <constructor-arg value = "#{elvis.age}" />
    

    or without elvis bean:

    <constructor-arg value = "#{T(com.xyz.Elvis).INSTANCE.age}" />
    
    0 讨论(0)
提交回复
热议问题