spring boot 读取配置文件

@Component
@PropertySource("classpath:url.properties")
@ConfigurationProperties(prefix = "vhall")
public class VhallUrl {

    private String userName;
	
    private String password;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

    //注意!配置一个PropertySourcesPlaceholderConfigurer的Bean
//    @Bean
//    public static PropertySourcesPlaceholderConfigurer propertyConfigure() {
//        return new PropertySourcesPlaceholderConfigurer();
//    }
	
}

  参考:http://blog.csdn.net/flygoa/article/details/58075398

猜你喜欢

转载自ln-software.iteye.com/blog/2397240