Skip to content

Instantly share code, notes, and snippets.

@Qkyrie
Created December 5, 2013 10:39
Show Gist options
  • Save Qkyrie/7803298 to your computer and use it in GitHub Desktop.
Save Qkyrie/7803298 to your computer and use it in GitHub Desktop.
PropertyPlaceholder in spring
@Configuration
@ImportResource("classpath:/com/acme/properties-config.xml")
public class AppConfig {
private @Value("${jdbc.url}") String url;
private @Value("${jdbc.username}") String username;
private @Value("${jdbc.password}") String password;
public @Bean DataSource dataSource() {
return new DriverManagerDataSource(url, username, password);
}
}
jdbc.properties
jdbc.url=jdbc:hsqldb:hsql://localhost/xdb
jdbc.username=sa
jdbc.password=
<beans>
<context:property-placeholder location="classpath:/com/acme/jdbc.properties"/>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment