Another way of achieving the same result is to use the @Value annotation:
public class Main {
private Country country;
@Autowired
public void setCountry(@Value("#{country}") Country country) {
this.country = country;
}
}
In this case, the "#{country}
string is an Spring Expression Language (SpEL) expression which evaluates to a bean named country
.