我一直在想如何通过配置文件运行嵌入式数据库,并且能够通过邮递员运行REST调用。 这是我到目前为止有:用mvn码头运行嵌入式H2数据库:运行
<profile>
<id>developRest</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
<configuration>
<driver>org.h2.Driver</driver>
<url>jdbc:h2:mem:test</url>
<username>sa</username>
<password>sa</password>
</configuration>
<executions>
<execution>
<id>my-execution</id>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/test/resources/table-ddl.sql</srcFile>
<srcFile>src/test/resources/insert-into-table.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<webApp>
<descriptor>src/main/webapp/WEB-INF/jetty.xml</descriptor>
</webApp>
<stopKey></stopKey>
<stopPort></stopPort>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
</profile>
我和周围的阶段播放,但没有什么似乎坚持。当我运行这个与MVN SQL:执行@我-执行码头:运行时,servlet运行,但一旦我所说的休息方法,我得到
Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (my-execution) on project myProject: The parameters 'driver', 'url' for goal org.codehaus.mojo:sql-maven-plugin:1.5:execute are missing or invalid
我缺少什么,将让驾驶者和URL是有效的?谢谢你的帮助。
更新:用于mvn -PdevelopRest sql:[email protected] jetty:run
摆脱了驱动程序和URL错误的,但还是坚持了:
### Error querying database. Cause: org.h2.jdbc.JdbcSQLException: Table "myTable" not found; SQL statement:
当调用从邮递员GET。有什么想法吗?
我最终没有使用内存数据库。我真的希望能够(因为它非常方便!)。但你说得对,因为它不会持续下去,我希望我能弄清楚。谢谢你的建议。由于尝试在其余呼叫中连接到数据库,Maven错误弹出。但是,因为我切换到使用H2服务器,并连接到该数据库,我不再因为数据库持续存在而出现错误。再次感谢! – Kevin