在我們的生產和開發中,我們針對MSSQL數據庫進行開發。在seam test中更改persistence.xml
但是當我們運行我們的測試時,我們想要對HSQL數據庫進行處理。
更改DS文件是沒有問題的,所以它對HSQL運行,但從persitence.xml中的舊dialce仍然是MSSQL方言,所以我如何將其更改爲HSQL方言?
// Trind
在我們的生產和開發中,我們針對MSSQL數據庫進行開發。在seam test中更改persistence.xml
但是當我們運行我們的測試時,我們想要對HSQL數據庫進行處理。
更改DS文件是沒有問題的,所以它對HSQL運行,但從persitence.xml中的舊dialce仍然是MSSQL方言,所以我如何將其更改爲HSQL方言?
// Trind
您可以使用資源和測試資源過濾。
<filters>
<filter>src/main/filters/dev.filter.properties</filter>
<filter>src/test/filters/dev.filter.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
在dev.filter.properties文件定義hibernate.dialet屬性,使其在主測試目錄不同。
然後使用它在test和main中的persistence.xml文件。
見
http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
http://maven.apache.org/plugins/maven-resources-plugin/testResources-mojo.html
當我有不同的測試項目和正在測試的項目時,這是否工作? – Trind
如果你有2個獨立的項目,那麼你可以使用兩個單獨的persistence.xml文件,每個文件都包含它的方言。 – dcernahoschi
是否使用Spring框架? – ruslan
不,我使用Seam 2.2.2-Final,我們使用maven進行部署。 – Trind