Skip to content

Instantly share code, notes, and snippets.

@michail-nikolaev
Created September 9, 2012 22:40
Show Gist options
  • Save michail-nikolaev/3687748 to your computer and use it in GitHub Desktop.
Save michail-nikolaev/3687748 to your computer and use it in GitHub Desktop.
Spring - property inject using Configuration (without any xml)
@Configuration
@PropertySource("classpath:/file.properties")
public class BeanProducer {
@Inject
private Environment env;
@Bean
public SomeClass someClass() {
String key = env.getProperty("key");
return new SomeClass (key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment