Created
December 5, 2013 10:39
-
-
Save Qkyrie/7803298 to your computer and use it in GitHub Desktop.
PropertyPlaceholder in spring
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
@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); | |
} | |
} |
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
jdbc.properties | |
jdbc.url=jdbc:hsqldb:hsql://localhost/xdb | |
jdbc.username=sa | |
jdbc.password= |
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
<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