How to inject List of bean properties by spring SpEL?

I have a properties file for defining dynamic endpoints (name, host and port).

So I created a bean named 'EndPoint' with name, host and port as member variables.

How to inject server's host and port dynamically by using Spring @Value and SpEL?





public class EndPoint {

/** name */

private String name;

// hardcode server1 here

// how to inject server's host dynamically by name?

// @Value("${endpoint.#{}.host}")


private String host;


private int port;

public EndPoint(String name) { = name;




@PropertySource( //

value = { "classpath:conf/" }, ignoreResourceNotFound = true//


public class EndPointBeanConfig {


private Environment env;

@Bean(name = "endPoints")

public List endPoints() {

final List endPoints =...

Read More »

By: StackOverFlow - Monday, 12 March

Related Posts