方法の設定hibernate-ツールとmavenローカルの生成hibernate.cfg.xml,*.hbm.xml,POJOsとDAOs
-
27-09-2019 - |
質問
きずの仕方を教えてください。力mavenる前にマッピングしました。hbm.xml ファイルの自動生成hibernate.cfg.xml ファイルのパッケージですか。
自分のアイデアは、そういった利用hibernate-ツールにmavenの永続化層のための私の願います。くさんありがとうございます。hibernate.cfg.xmlそのすべてmy_table_names.hbm.xml 最後POJOの生成されます。しかし hbm2java
目標などを入れて*.hbm.xml ファイルの src/main/resources/package/path/
フォルダが hbm2cfgxml
指定のマッピングファイルだけがテーブルの名前、すなわち:
<mapping resource="MyTableName.hbm.xml" />
での大きな課題です:かの設定 hbm2cfgxml
そのhibernate.cfg.xml のように見え。
<mapping resource="package/path/MyTableName.hbm.xml" />
私pom.xml ようになりますの瞬間:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<implemetation>jdbcconfiguration</implementation>
<outputDirectory>src/main/resources/</outputDirectory>
</component>
</components>
<componentProperties>
<packagename>package.path</packageName>
<configurationFile>src/main/resources/hibernate.cfg.xml</configurationFile>
</componentProperties>
</configuration>
</execution>
</executions>
</plugin>
そして第の質問:はしてもらえると助かりますかmavenローカルコピー資源を対象フォルダを実行する前に、 hbm2java
?現在を使用してい
mvn clean resources:resources generate-sources
るものでなければなります。
させます。
更新:
@パスカル: ~ご協力ありがとうございました.のパスをマッピング動作が今、どうなるかはわからないが間違っていたの前にあります。ん、ありがとうございまでの一部の問題を文書hibernate.cfg.xml を読みながらconfigデータベースからでも、ファイル更新).
って削除されるファイルhibernate.cfg.xml差し替えでデータベースです。物件の目標 hbm2cfgxml
や hbm2hbmxml
.また利用がないの outputDirectory
も configurationfile
この目標です。
その結果、ファイル hibernate.cfg.xml
すべて *.hbm.xml
発生中の私の目標/hibernate3/生成-マッピング/フォルダのデフォルト値です。その後の更新に hbm2java
目次
<componentProperties>
<packagename>package.name</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
そこで、次の結果を得た:
[INFO] --- hibernate3-maven-plugin:2.2:hbm2java (hbm2java) @ project.persistence ---
[INFO] using configuration task.
[INFO] Configuration XML file loaded: file:/C:/Documents%20and%20Settings/mmm/workspace/project.persistence/target/hibernate3/generated-mappings/hibernate.cfg.xml
12:15:17,484 INFO org.hibernate.cfg.Configuration - configuring from url: file:/C:/Documents%20and%20Settings/mmm/workspace/project.persistence/target/hibernate3/generated-mappings/hibernate.cfg.xml
12:15:19,046 INFO org.hibernate.cfg.Configuration - Reading mappings from resource : package.name/Messages.hbm.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java (hbm2java) on project project.persistence: Execution hbm2java of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java failed: resource: package/name/Messages.hbm.xml not found
どのような取り扱う。もちろんのファンダメンタルズ:
<outputDirectory>src/main/resources/package/name</outputDirectory>
の hbm2hbmxml
目標といえそうではないの?あいち早く入手することができ すべての 生成されたコードおよび資源から src/
フォルダ?
を前提にしていることを目指して、このアプローチが発生しない源の私のsrc/main/java/resourcesフォルダでは、生成されたコード対象のフォルダにまとめた。私はこの視点は、今後もそれが実行 hbm2dao
包装のプロジェクトとして使用する発生する持続性層からコンポーネント事業。これもどう?
解決
かの設定hbm2cfgxmlうhibernate.cfg.xml のように見え下(...)
いプロジェクトを使用している hbm2cfgxml
の <mapping resource="..."/>
帳を反映し、パッケージ名のパス hbm.xml
.があるのでもう一度サービス"をお選びください。ここにいくつかの例があります:
- 私のbind
hbm2cfgxml
のgenerate-resources
相んな発生源 - かのファイル
src/main/resources
ですがtarget/classses
(なぜ入れて発生するものは、ソースツリーがほしいclean
清潔です。 - が、誤植で
configurationfile
, ないconfigurationFile
が--- - なぜ、地獄をお願いしま
<configurationfile>
の構成hbm2cfgxml
?生成してくださいのでこちら---私は取り外してください。
更新: ございますのでご注意下さい、情報の必要な接続にはデータベース src/main/resources/database.properties
(デフォルトの値は、 propertyfile
財らない src/main/resources/hibernate.cfg.xml
(削除するファイル).以下にサンプル database.properties
:
hibernate.connection.driver_class=org.apache.derby.jdbc.ClientDriver
hibernate.connection.url=jdbc:derby://localhost:1527//home/pascal/Projects/derbyDBs/EMPLDB
hibernate.connection.username=APP
hibernate.connection.password=APP
hibernate.dialect=org.hibernate.dialect.DerbyDialect
と申し上げたように、削除の src/main/resources/hibernate.cfg.xml
ファイルを生成してくださいます。
はしてもらえると助かりますかmavenローカルコピー資源を対象フォルダを実行する前に、hbm2java?(...)
の hbm2java
目標 を呼び出しの実行のライフサイクルの位相プロセス資源の実行に際しても からの文書).このデフォルトの挙動が生じた hibernate3:hbm2java
または generate-sources
の場合 hbm2java
されます。
他のヒント
Ok、固定の私の問題により強mavenの hbm.xml
ファイルの /target/授業/パッケージ名 フォルダのように私のpomようになります:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<implementation>jdbcconfiguration</implementation>
</component>
</components>
<componentProperties>
<packagename>package.name</packagename>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2hbmxml</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2hbmxml</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>target/classes</outputDirectory>
</component>
</components>
<componentProperties>
<packagename>package.name</packagename>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
</component>
</components>
<componentProperties>
<packagename>package.name</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2dao</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2dao</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2dao</name>
<implementation>configuration</implementation>
</component>
</components>
<componentProperties>
<packagename>package.name</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
でもokです。としてfasとしていかな、っての早期構築の段階でその hbm.xml
ファイルからコピーすること 目標/hibernate3/生成-マッピング (い発生するデフォルト) 対象者/授業/パッケージ名 (hibernate-ツールに見えても私の場合ではないと分かるものになっているとともにがあれば、誰もが知ることは何かになっているかを教えてください.そうでないなんて言わずもがなである。
いわれていることがありう機会を設けていきたいと思い働きたいこのパッケージの名前は、生成されPOJOsとDAOs:が作成した別のスレッドがこの こちらの.
更新: okたものの、今後もます。の問題が不足していパッケージ名の hbm2hbmxml
目標の設定をします。だったので買ってきたの componentProperties と パッケージ名 が、発生する hbm.xml
の全種類のクラス名です。更新した上記のpom、現在です。に関する問題を明示的で転載-複製を行 hbm.xml
ファイルを 対象者/授業 フォルダものです。
たとえばどのように使うか、Hibernateのツールmavenを使用せずhibernate3-maven-pluginチェック このポスト.その考え方としては、実行HibernateツールのAntタスクとMaven.このアプローチは完全に制御します。