public static final String STUDENTS = "studentsInfo";
@Bean(name = "students")
public List<Student> getStudents() {
String configuredStudents = env.getProperty("studentsInfo"); //JSON having list of students info
List<Student> students;
if (configuredStudents != null) {
try {
students =
Arrays.asList(
JsonUtilFactory.getInstance(JsonUtilFactory.JsonUtilType.LOCAL)
.toObject(configuredStudents, Student[].class));
} catch (Exception e) {
}
}
return students;
}
- I'm able to refresh env variable [i.e without system restart
@RefreshScope and spring-cloud-starter-kubernetes-config]. How to make those changes to bean students ?
- Also if I have to partially update JSON [say add a new student], what would be the right approach?