title: Spring Boot / JPA / Hibernate, How to switch database vendor according to Spring profile?
body: <p>I'm using Spring Boot / JPA / Hibernate. I would like to use HSQLDB when testing on localhost and MySQL when deploying on server.</p>
  
  <p>In pom.xml, I have this dependency for MySQL :</p>
  
  <pre><code> &lt;dependency&gt;
      &lt;groupId&gt;mysql&lt;/groupId&gt;
      &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
   &lt;/dependency&gt;
  </code></pre>
  
  <p>and this dependency for HSQLDB :</p>
  
  <pre><code>&lt;dependency&gt;
     &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
     &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I probably can't put both dependencies in pom.xml due to Spring Boot autoconfiguration. But I would like to use HSQLDB when the <code>local</code> Spring profile is active and use MySQL when the <code>server</code> Spring profile is active. Ideally, I would like to generate only one war file and running the local version with <code>mvn spring-boot:run</code> and deploy the server version from the war file.</p>
  
  <p>Any idea?</p>
  
  <p>P.S.: I'm using maven</p>