Skip to content

Instantly share code, notes, and snippets.

@snicoll
Created July 10, 2015 19:38
Show Gist options
  • Save snicoll/b2b08f783014ed2c6f02 to your computer and use it in GitHub Desktop.
Save snicoll/b2b08f783014ed2c6f02 to your computer and use it in GitHub Desktop.
package demo;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;
@SpringBootApplication
@EnableConfigurationProperties(DemoApplication.FooProperties.class)
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Service
public static class Startup {
@Autowired
private FooProperties fooProperties;
@PostConstruct
public void test() {
System.out.println("Name --> " + fooProperties.getName());
System.out.println("Description --> " + fooProperties.getDescription());
}
}
//@ConfigurationProperties
public static class FooProperties {
private String name;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment