Calling methods
Call the Application.properties property value @Value annotation:
@Value ("${com.ieen.super.name}") private String name;
To invoke a custom properties property value @Value annotation:
@PropertySource ("Classpath:conf/boot.properties") public class main{ @Value ("${com.ieen.boot.name}") Private String Bootname;}
Note:@PropertySource annotations are introduced into custom properties starting from 1.5
Value is custom Config//ignoreresourcenotfound default false, file does not exist error//Encoding set encoding//name for resource object Beanname@propertysource ( Value = {"Classpath:boot.properties", "Classpath:conf/boot.properties"}, Ignoreresourcenotfound = False, encoding = "UTF-8", name = "Boot-custom.properties")
@ConfigurationProperties Configure the Properties Property object:
Spring Boot 1.5 Previous configuration//@ConfigurationProperties (prefix = "com.ieen.boot", locations = "classpath:conf/ Boot.properties ") @ConfigurationProperties (prefix =" Com.ieen.boot ")
If the custom properties is added @propertysource (value = "Classpath:conf/boot.properties", encoding = "UTF-8") @Componentpublic Class Bootpropertiesbean { private String name; private String value; Public String GetName () { return name; } public void SetName (String name) { this.name = name; } Public String GetValue () { return value; } public void SetValue (String value) { this.value = value; }}
@Autowired private Bootpropertiesbean bean;