apache ant設定及使用(資料庫自動建構bean)

apache ant下載網頁http://ant.apache.org/bindownload.cgi
環境變數中加入ANT_HOME=c:\ant\bin(ant放的目錄),JAVA_HOME=c:\java\jre7\bin
path加入%ANT_HOME%;%JAVA_HOME%
注意事項:

  1. 資料庫欄位名稱要有一個table名稱+Id,欄位型態為integer not null auto_increment,(自動加1)
  2. db.properties中設定資料庫的連線方式
    • hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
    • hibernate.connection.driver_class = com.mysql.jdbc.Driver
    • hibernate.connection.url = jdbc:mysql://localhost/ 資料庫名稱
    • hibernate.connection.username = 資料庫連線USER名稱
    • hibernate.connection.password =  資料庫連線密碼
  3. reveng.xml設定要轉的TABLE
    • <hibernate-reverse-engineering>
    • <table-filter match-name=".*" package="hello"/>(資料庫table全部轉,bean放到hello的目錄)
    • </hibernate-reverse-engineering>
  4. 執行命令:ant reveng.entities

留言

這個網誌中的熱門文章

java 數字轉字串 字串轉數字

MS sqlServer資料庫移轉至MySQL-->利用MySQL WorkBench

sql server 15023 error [SQL SERVER問題: 使用者、組或角色 '*****' 在當前資料庫中已存在]