To get property key-value from .properties file,
1) Declare <context:property-placeholder> tag in spring xml.
2) Declare a variable with required type and annotate the variable with @value.
Ex:
env.properties
--------------
user.name=prabha
user.has.phone=true
in java class
------------
@value("${useer.name}")
private String name;
@value("${user.has.phone}")
private boolean hasPhone;
//setters and getters
1) Declare <context:property-placeholder> tag in spring xml.
2) Declare a variable with required type and annotate the variable with @value.
Ex:
env.properties
--------------
user.name=prabha
user.has.phone=true
in java class
------------
@value("${useer.name}")
private String name;
@value("${user.has.phone}")
private boolean hasPhone;
//setters and getters
No comments:
Post a Comment