title: Why can I run JUnit tests for my Spring project, but not a main method?
body: <p>I am using JDBC to connect to MySQL for a small application.  In order to test without altering the real database, I'm using HSQL in memory for JUnit tests.</p>
  
  <p>I'm using Spring for DI and DAOs.  Here is how I'm configuring my HSQL DataSource</p>
  
  <pre><code>&lt;bean id="mockDataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource"&gt;
      &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver"/&gt;
      &lt;property name="url" value="jdbc:hsqldb:mem:mockSeo"/&gt;
      &lt;property name="username" value="sa"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>This works fine for my JUnit tests which use the mock DB.  But when I try to run a main method, I find the following error:</p>
  
  <pre><code>Error creating bean with name 'mockDataSource' defined in class path resource [beans.xml]: 
  Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
  PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: 
  Could not load JDBC driver class [org.hsqldb.jdbcDriver]
  </code></pre>
  
  <p>I'm running from Eclipse, and I'm using the Maven plugin.  Is there a reason why this would work as a Test, but not as a <code>main()</code>?  I know that the <code>main</code> method itself is not the problem, because it works if I remove all references to the HSQL DataSource from my Spring Configuration file.</p>