Spring EL in Annotation(Annotation-based configuration):-
The @Value annotation can be placed on fields, methods and method/constructor
parameters to specify a default value.
1 This is the first class .
package com.r4r.in;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("studBean")
public class Student {
@Value("#{empBean}")
private Name name;
@Value("#{empBean.name}")
private String studName;
//...
}
2 This is second class.
package com.r4r.in;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("empBean")
public class Employee {
@Value("vipul") //inject String directly
private String name;
@Value("20") //inject interger directly
private int age;
public String getName() {
return name;
}
//...
}