0

my Properties file is like this

customer1.username = "";
customer1.passwword ="";
customer1.integratorkey=""

customer2.username = "";
customer2.passwword ="";
customer2.integratorkey=""

Is there a way I can use @Value annotation and load the value in a data structure with all the six values in it

avenirit12
  • 233
  • 2
  • 5
  • 17

2 Answers2

1

Java code with @Value annotation:

 @Value("${customer1.username}")
 private String customer1Username;
dogankadriye
  • 538
  • 3
  • 13
  • This does not works for me I want all the six values in a map or similar datastructure . I did know the simple usage of @value annotation – avenirit12 Aug 19 '15 at 15:31
  • I couldn't find usage of @Value to inject bean list from .properties file, generally it's using for simple types , example code is : http://stackoverflow.com/questions/12576156/reading-a-list-from-properties-file-and-load-with-spring-annotation-value You can define your bean list in your .xml file then inject to your application. – dogankadriye Aug 20 '15 at 06:07
0

You can make a Bean and set the attributes with the properties. Something like this:

<bean id="example1" class="ar.com.whetever.ExampleImpl">
        <property name="attribute1" value="${customer1.username}" />
        <property name="attribute2" value="${customer2.passwword}" />
</bean>
Tupac
  • 647
  • 12
  • 37