我一直在想如何通過配置文件運行嵌入式數據庫,並且能夠通過郵遞員運行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