title: How to create Spring Security 3.1 Datasource bean in a java class
body: <p>I am new to JSF and Spring Security.
  I am building a JSF 2 project based on <a href="http://mprabhat.com/2012/07/11/spring-security-3-1-and-jsf-2-0-custom-form/" rel="nofollow">this tutorial</a>. I want to put the dataSource bean in a java class because I am generating the url for the JDBC connection and users in another class.
  How to put this code from my security-config.xml to a java class.</p>
  
  <pre><code> &lt;beans:bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;beans:property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;beans:property name="url" value="jdbc:mysql://localhost:3306/spring_security_db" /&gt;
      &lt;beans:property name="username" value="root" /&gt;
      &lt;beans:property name="password" value="" /&gt;
   &lt;/beans:bean&gt;
  </code></pre>