Spring - using static final fields (constants) for bean initialization

前端 未结 5 974
轻奢々
轻奢々 2020-12-07 17:07

is it possible to define a bean with the use of static final fields of CoreProtocolPNames class like this:




        
5条回答
  •  隐瞒了意图╮
    2020-12-07 17:56

    Something like this (Spring 2.5)

    
        
            
        
    
    

    Where util namespace is from xmlns:util="http://www.springframework.org/schema/util"

    But for Spring 3, it would be cleaner to use the @Value annotation and the expression language. Which looks like this:

    public class Bar {
        @Value("T(java.lang.Integer).MAX_VALUE")
        private Integer myValue;
    }
    

提交回复
热议问题