2011-12-21 77 views
1

我在glassfish中使用Eclipselink部署應用程序,我想使用新的Eclipse 2.3屬性DEPLOY_ON_STARTUP加速我的事情一點。我爲我的開發使用了Netbean 7.0和glassfish 3.1.1。使用Eclipselink JPA:如何在persistence.xml中設置啓動時的部署

我的問題是:如何在Persistence.xml中設置它?我嘗試了以下方法,無法部署。

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence".... 

    <persistence-unit name="MyPU" transaction-type="JTA"> 
    <jta-data-source>myDataSource</jta-data-source> 
    <exclude-unlisted-classes>false</exclude-unlisted-classes>  

    <properties> 
     <DEPLOY_ON_STARTUP>True</DEPLOY_ON_STARTUP> 
    </properties> 

    </persistence-unit> 

</persistence> 

如果非要在代碼中設置該屬性,我該怎麼辦呢?在維基的EclipseLink說:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu-name", props); 

但是我使用@EJB註解,我不管理我的代碼的EntityManagerFactory或實體。

回答

1

您的方法不起作用,因爲properties-element內的元素應該是property-elements,它們是name-value -pairs。嘗試

<property name="eclipselink.deploy-on-startup" value="True" /> 

改爲。我不知道沒有給出這樣的速度提高要搜索的內容,根據的javadoc:

這可能會增加的JavaEE服務器的啓動時間,但會避免爲持久性單元部署懸掛 第一個請求。

+0

謝謝。有用。我的第一個Web服務調用總是很慢。通過增加這個,希望它會加快一點點。 – neo 2011-12-22 20:04:54

相關問題