I have spring-boot application based on maven.
I want to have h2 database as dependency only for tests so I have it as follows:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
then I need one maven profile for development which needs h2 as compile or runtime dependency:
<profile>
<id>emb</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<!-- Using embedded database in development -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
But it still failing on "Cannot load driver class: org.h2.Driver" as it is using test scope only.
When I removed test scope specification from dependency it works but it is not what I want since I don't want to have in production.
Any possibility how to rewrite dependency scope based on profile?