Middlegen配置
19/04/13 19:37 Filed in: java
@+++++++++++++++++++++
@+ Ant配置 +@
@+++++++++++++++++++++
Ant解压到MiddleGen目录,下面假设目录为C:\Middlegen\Ant 更改/修改环境变量 ------------------------------------------------------------------------------------ ANT_HOME C:\Middlegen\Ant PATH %ANT_HOME%\bin; ------------------------------------------------------------------------------------
@+++++++++++++++++++++ @+ MiddleGen配置 +@ @+++++++++++++++++++++
********************************************** ** 解压完成后修改根目录下 build.xml ** **********************************************
(1)首先更改目标数据库配置文件地址 查找关键字 ”!ENTITY”,得到 ------------------------------------------------------------------------------------ ]> ------------------------------------------------------------------------------------ 默认情况下,采用的是hsqldb.xml,将其修改为我们所用的数据库配置文件(mysql.xml)
(2)Application name 查找 ------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
将airline修改为我们所希望的应用程序名称
(3)输出目录 查找关键字“name="build.gen-src.dir"”,得到 ------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
修改value="${build.dir}/gen-src"使其指向我们所期望的输出目录
(4)对应代码的Package name 查找关键字“destination”,得到 ------------------------------------------------------------------------------------
destination="${build.gen-src.dir}"
package="${name}.hibernate" -->更改为我们需要的包名
genXDocletTags="false" -->设置成true生成以后进行映射提供帮助
genIntergratedCompositeKeys="false"
javaTypeMapper= "middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>
------------------------------------------------------------------------------------
注意:如果是SQLServer,需要将下面
------------------------------------------------------------------------------------
schema="${database.schema}"
catalog="${database.catalog}"
------------------------------------------------------------------------------------
删除,否则Middlegen会报出找不到表的错误
****************************************************** ** 配置\config\database子目录对应的数据库xml文件,如mysql.xml ** ******************************************************
------------------------------------------------------------------------------------
value="jdbc:mysql://localhost:3306/testDB?
useUnicode=true&characterEncoding=gb2312"/>
------------------------------------------------------------------------------------
=================在MiddleGen 根目录下运行ant,就将出现MiddleGen的界面=================
********************************* ** hbm2java 一般配置 ** ********************************* 修改文件extensions\tools\bin\setenv.bat ------------------------------------------------------------------------------------ @echo off set JDBC_DRIVER=C:\Middlegen\lib\mm.mysql-2.0.4-bin.jar -->JDBC包 set HIBERNATETOOLS_HOME=C:\Middlegen\extensions -->extensions主目录 set HIBERNATE_HOME=C:\Middlegen\hibernate -->hibernate主目录 rem echo HIBERNATETOOLS_HOME set to %HIBERNATETOOLS_HOME%
if "%HIBERNATE_HOME%" == "" goto noHIBERNATEHome
set CORELIB=%HIBERNATE_HOME%\lib set LIB=%HIBERNATETOOLS_HOME%\lib set CP=%CLASSPATH%;%JDBC_DRIVER%;%HIBERNATE_HOME%\hibernate2.jar; %CORELIB%\commons-logging-1.0.4.jar;%CORELIB%\commons-lang-1.0.1.jar; %CORELIB%\cglib-full-2.0.2.jar;%CORELIB%\dom4j-1.4.jar;%CORELIB%\odmg-3.0.jar; %CORELIB%\xml-apis.jar;%CORELIB%\xerces-2.4.0.jar;%CORELIB%\xalan-2.4.0.jar; %CORELIB%\jdom.jar;%CORELIB%\commons-collections-2.1.1.jar; %CORELIB%\hibernate-tools.jar -->重点说明:保证根据上面的设置能找到这些包
if not "%HIBERNATE_HOME%" == "" goto end
:noHIBERNATEHome echo HIBERNATE_HOME is not set. Please set HIBERNATE_HOME. goto end
:end ------------------------------------------------------------------------------------ 在目录下执行C:\Middlegen\extensions\tools\bin>hbm2java c:\middlegen\workshop\test\*.xml --output=c:\middlegen\workshop即可
Ant解压到MiddleGen目录,下面假设目录为C:\Middlegen\Ant 更改/修改环境变量 ------------------------------------------------------------------------------------ ANT_HOME C:\Middlegen\Ant PATH %ANT_HOME%\bin; ------------------------------------------------------------------------------------
@+++++++++++++++++++++ @+ MiddleGen配置 +@ @+++++++++++++++++++++
********************************************** ** 解压完成后修改根目录下 build.xml ** **********************************************
(1)首先更改目标数据库配置文件地址 查找关键字 ”!ENTITY”,得到 ------------------------------------------------------------------------------------ ]> ------------------------------------------------------------------------------------ 默认情况下,采用的是hsqldb.xml,将其修改为我们所用的数据库配置文件(mysql.xml)
(2)Application name 查找 ------------------------------------------------------------------------------------
(3)输出目录 查找关键字“name="build.gen-src.dir"”,得到 ------------------------------------------------------------------------------------
(4)对应代码的Package name 查找关键字“destination”,得到 ------------------------------------------------------------------------------------
注意:如果是SQLServer,需要将
****************************************************** ** 配置\config\database子目录对应的数据库xml文件,如mysql.xml ** ******************************************************
------------------------------------------------------------------------------------
=================在MiddleGen 根目录下运行ant,就将出现MiddleGen的界面=================
********************************* ** hbm2java 一般配置 ** ********************************* 修改文件extensions\tools\bin\setenv.bat ------------------------------------------------------------------------------------ @echo off set JDBC_DRIVER=C:\Middlegen\lib\mm.mysql-2.0.4-bin.jar -->JDBC包 set HIBERNATETOOLS_HOME=C:\Middlegen\extensions -->extensions主目录 set HIBERNATE_HOME=C:\Middlegen\hibernate -->hibernate主目录 rem echo HIBERNATETOOLS_HOME set to %HIBERNATETOOLS_HOME%
if "%HIBERNATE_HOME%" == "" goto noHIBERNATEHome
set CORELIB=%HIBERNATE_HOME%\lib set LIB=%HIBERNATETOOLS_HOME%\lib set CP=%CLASSPATH%;%JDBC_DRIVER%;%HIBERNATE_HOME%\hibernate2.jar; %CORELIB%\commons-logging-1.0.4.jar;%CORELIB%\commons-lang-1.0.1.jar; %CORELIB%\cglib-full-2.0.2.jar;%CORELIB%\dom4j-1.4.jar;%CORELIB%\odmg-3.0.jar; %CORELIB%\xml-apis.jar;%CORELIB%\xerces-2.4.0.jar;%CORELIB%\xalan-2.4.0.jar; %CORELIB%\jdom.jar;%CORELIB%\commons-collections-2.1.1.jar; %CORELIB%\hibernate-tools.jar -->重点说明:保证根据上面的设置能找到这些包
if not "%HIBERNATE_HOME%" == "" goto end
:noHIBERNATEHome echo HIBERNATE_HOME is not set. Please set HIBERNATE_HOME. goto end
:end ------------------------------------------------------------------------------------ 在目录下执行C:\Middlegen\extensions\tools\bin>hbm2java c:\middlegen\workshop\test\*.xml --output=c:\middlegen\workshop即可