2012-04-24 10 views

答えて

0

:build.propertiesは、あなたが

<username>@[email protected]</username> 
<password value="@[email protected]"/> 

のような値を持つことにpersistence.xmlを変更することができますプロパティなど

username = root 
password = shoot 

が含まれていますそして、あなたのbuild.xmlはこの意志のようなものでなければなりません作業。

<target name="replace"> 
    <property file="build.properties"/> 
    <replace file="persistence.xml" token="@[email protected]" value="${username}"/> 
    <replace file="persistence.xml" token="@[email protected]" value="${password}"/> 
</target> 

はここでユーザ名とパスワード$の値が自動的に<property>タグから蟻によって識別されます$とは、名前のように、キーと値にアクセスすることができます。

+0

どのように私はpersistence.xmlにbuild.propertiesの値を挿入できますか?これらのリンクはpersistence.xmlを表示していません。 build.xmlが実行されている間に値をbuild.propertiesからpersistence.xmlに取得する必要があります。つまり、値がpersistence.xmlで自動的に反映されるはずです。 – user1340856

+0

それをやって。 – Phani

+0

申し訳ありません。このリンクからは何も分かりませんでした。このタグは実際に何をしていますか? – user1340856

0

私は自分自身を思い出さなければなりませんでした。それを行うための正しい方法は、私はあなたのbuild.propertiesファイルからそれを読んで、一時的にそこに行ったようにあなたの代わりに、ユーザー名をハードコーディングすることができ、そのような

Map<String, String> props = new HashMap<String, String>(); 
    props.put("hibernate.connection.username", "sa"); 
    props.put("hibernate.connection.password", ""); 
    props.put("hibernate.connection.url", "jdbc:h2:mem:test_mem;MVCC=true"); 
    EntityManagerFactory factory = Persistence.createEntityManagerFactory("inmemory", props); 

です。楽しむ。

ディーン

関連する問題