1. Inject to properties file in Spring Bean using PropertyPlaceholderConfigurer
bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
classpath:com/foo/jdbc.properties
2. Use the injected properties in your bean class. Here taking example of dataSource.
${jdbc.driverClassName}"/>
${jdbc.url}"/>
${jdbc.username}"/>
${jdbc.password}"/>
3. The Content of properties file is below
The actual values come from another file in the standard Java
Properties format:
jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:hsql://production:9002
jdbc.username=sa
jdbc.password=root
No comments:
Post a Comment