Created
July 10, 2015 19:38
-
-
Save snicoll/b2b08f783014ed2c6f02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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