1. Install the plug-in
Download eclipse plugin from http://ibatis.apache.org/abator.html. There are two plugin installation methods.
1. Remote Installation.
Eclipse-> help> Software Updates> Find and install-> search for new features to install->
New remote site (Name: abator for eclipse Update site, URL: http://ibatis.apache.org/tools/abator)
-> OK-> abator for eclipse Update site-> OK
2. Manual Installation.
Bytes
Eclipse-> help> Software Updates> Find and install-> search for new features to install (Press "Next")->
New local site-> select the file you just downloaded-> OK
2. Create a project
Create an Eclipse project, enter the name, select File> New> abator for ibatis configuration file, select location, and type file name: abatorcsonfig. xml.
Click "finish". eclipse will create the abatorcsonfig. xml file under the root directory of the program and open and edit it. The content is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE abatorConfiguration PUBLIC "-// Apache Software Foundation // DTD Abator for iBATIS Configuration 1.0 //" http://ibatis.apache.org/dtd/abator-config_1_0.dtd ">
<AbatorConfiguration>
<AbatorContext>
<JdbcConnection driverClass = "driver" connectionURL = "Database URL" userId = "username" password = "password">
<ClassPathEntry location = "database driver jar package"/>
</JdbcConnection>
<JavaModelGenerator targetPackage = "model layer package name" targetProject = "project name"/>
<SqlMapGenerator targetPackage = "map layer package name" targetProject = "project name"/>
<DaoGenerator targetPackage = "dao layer package name" targetProject = "project name" type = "IBATIS"/>
<Table schema = "Mode name" tablename = "table name" catalog = "Database Name"> be sure to write it down. Otherwise, an error will be reported.
</Table>
</Abatorcontext>
</Abatorconfiguration>
Right-click abatorcsonfig. xml and select generate ibatis artifact. The model, map, and Dao directories are generated under the src directory, and the files are created.
Javamodelgenerator: valueobject
Sqlmapgenerator: XML file
Daogenerator: code for placing interfaces and Dao
Write an sqlserver example to show you:
My project name is ibatistest
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype abatorconfiguration public "-// Apache Software Foundation // DTD abator for ibatis configuration 1.0 //" http://ibatis.apache.org/dtd/abator-config_1_0.dtd ">
<Abatorconfiguration>
<Abatorcontext>
<Jdbcconnection driverclass = "com. microsoft. JDBC. sqlserver. sqlserverdriver "connectionurl =" JDBC: sqlserver: // localhost: 1433; databasename = sunlight "userid =" sa "Password =" ">
<Classpathentry location = "E:/ibatistest/lib/MSSQLServer. Jar"/>
<Classpathentry location = "E:/ibatistest/lib/msutil. Jar"/>
<Classpathentry location = "E:/ibatistest/lib/msbase. Jar"/>
</Jdbcconnection>
<JavaModelGenerator targetPackage = "com. accp. model" targetProject = "IbatisTest"/>
<SqlMapGenerator targetPackage = "com. accp. maps" targetProject = "IbatisTest"/>
<DaoGenerator targetPackage = "com. accp. dao" targetProject = "IbatisTest" type = "IBATIS"/>
<Table tableName = "stu" schema = "dbo" catalog = "sunlight">
</Table>
</AbatorContext>
</AbatorConfiguration>