java - Referring applicationContext.xml bean in Spring @Configuration -


i have this:

    @configuration     public class springconfigutil {          private static final logger logger = logger.getlogger(springconfigutil.class);           @value("#{ systemproperties['activemq.username'] }")          private string username;          @value("#{ systemproperties['activemq.password'] }")          private string password;          @value("#{ systemproperties['activemq.url'] }")          private string brokerurl;          @value("#{ systemproperties['activemq.queuename'] }")          private string queuename;            @bean          public static propertysourcesplaceholderconfigurer placeholderconfigurer() {             return new propertysourcesplaceholderconfigurer();           }           @bean(name="producer")          public jmstemplate jmstemplate() {             jmstemplate jmstemplate = new jmstemplate();             jmstemplate.setdefaultdestination(new activemqqueue(queuename));             jmstemplate.setconnectionfactory(connectionfactory());             return jmstemplate;         }           @bean         public activemqconnectionfactory connectionfactory() {             activemqconnectionfactory activemqconnectionfactory = new activemqconnectionfactory();             activemqconnectionfactory.setbrokerurl(brokerurl);             activemqconnectionfactory.setusername(username);             activemqconnectionfactory.setpassword(password);                       return activemqconnectionfactory;         }     } 

it works fine. let's have applicationcontext.xml file has loaded beans.

how refer beans here in @configuration? don't want create beans programmatically again created loading applicationcontext.xml.

let's have have 50+ properties. there better way refer them defining following every property?

  @value("#{ systemproperties['activemq.url'] }")      private string brokerurl; 

thanks time!

how refer beans here in @configuration?

according http://docs.spring.io/spring-javaconfig/docs/1.0.0.m4/reference/html/ch06.html, please try:

... @configuration @annotationdrivenconfig // enable @autowired annotation (??) @importxml("classpath:<*path*/to/your/*>applicationcontext.xml") public class springconfigutil { ... 

let's have have 50+ properties. there better way refer them defining following every property?

none, can imagine :-( ... how "better access" 50+ properties, "by name" - "by index", array-like!? though properties can coupled, @ end of day" each has (should have) special meaning , purpose - , touched/wired/configured individually. (the best practice tip rare possible)


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -