title: Spring: Accessing environment variables inside applicationConfig.xml
body: <p>I would like to set my db credentials and other secret values as part of environment variables. Is there a way of accessing the environment variables inside applicationConfig.xml</p>
  
  <p>I tried <code>&lt;property name="username" value="#{systemEnvironment['db_username']}" /&gt;</code>. However this did not work. Am I missing something?</p>
  
  <p>Many were telling me how to access values from a properties file. I need to access the environment variable directly.</p>
  
  <p>My code is as follows:-</p>
  
  <pre><code>&lt;context:component-scan base-package="org.dhana.*" /&gt;
  
      &lt;context:annotation-config /&gt;
  
      &lt;bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
  
  
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url"
              value="xxxx" /&gt;
          &lt;property name="username" value="${db_username}" /&gt;
          &lt;property name="password" value="xxxxx" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  </code></pre>