The connected database is SQL server2008, so the file you need is Sqljdbc4.jar
The Lib libraries you use are:
Create a new src folder under the Lib Library directory to hold the generated files, and then create a new Generatorconfig.xml
The code inside is:
<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis generator Configuration.//en" "http://mybatis.org/ Dtd/mybatis-generator-config__.dtd "> <generatorConfiguration> <!--database driver--> <!-- Sqljdbc4.jar is a SQL Server database connection jar package, if you want to connect the MySQL database directly sqljdbc4.jar to Mysql-connector-java-5.1.25-bin.jar--> < Classpathentry location= "Sqljdbc.jar"/> <context id= "dbtables" targetruntime= "MyBatis" > < commentgenerator> <property name= "Suppressdate" value= "true"/> <!--remove automatically generated comments true: false: No--> ;p roperty name= "suppressallcomments" value= "true"/> </commentGenerator> <!--database link URL, user name, password--> <! --Connecting data SQL Server--> <jdbcconnection driverclass= "Com.microsoft.sqlserver.jdbc.SQLServerDriver" Connectionurl
= "Jdbc:sqlserver://127.0.0.1:1433;databasename=dbssmtest" userid= "sa" password= "123" > <!--connection database MySQL--> <!--<jdbcconnection driverclass= "Com.mysql.jdbc.Driver "connectionurl=" Jdbc:mysql://...:/ypzlmanagement "userid=" root "password=" Hewei ">--> </jdbcConnection> <javaTypeResolver> <property name= "Forcebigdecimals" value= "false"/> </ Javatyperesolver> <!--the package name and location of the build model--> <!--targetpackage= "Com.ssm.pojo" is the repository path for the generated code here, according to your path--> < Javamodelgenerator targetpackage= "Com.ssm.pojo" targetproject= "src" > <property name= "enablesubpackages" value = "true"/> <property name= "trimstrings" value= "true"/> </javaModelGenerator> <!--generate the package name and location of the mapping file- > <!--targetpackage= "Com.ssm.pojo" is the storage path of the generated code here--> <sqlmapgenerator targetpackage= according to your path Com.ssm.mapping "targetproject=" src "> <property name=" enablesubpackages "value=" true "/> </ Sqlmapgenerator> <!--generate the package name and location of DAO--> <!--targetpackage= "Com.ssm.pojo" is the repository path for the generated code here, according to your path--> < Javaclientgenerator type= "Xmlmapper" targetpackage= "Com.ssm.dao" targetproject= "src" > <pRoperty name= "Enablesubpackages" value= "true"/> </javaClientGenerator> <!--the table to be generated tablename is the name of the table or view in the database Domainobjectname is the entity class name--> <!--TableName is the name of the table to generate the database mapping file domainobjectname The entity class name to generate the code changes--> according to its own needs <table
Tablename= "Student" domainobjectname= "student" enablecountbyexample= "false" enableupdatebyexample= "false" Enabledeletebyexample= "false" enableselectbyexample= "false" Selectbyexamplequeryid= "false" ></table> < /context> </generatorConfiguration>
Finally, locate the root directory of Lib under the CMD console and execute the following statement
Java-jar Mybatis-generator-core-1.3.5.jar-configfile Generatorconfig.xml-overwrite
As shown in the figure:
Then you can see the automatically generated files in the folder directory
The above is a small set to introduce the detailed MyBatis generator automatically create code (Dao,mapping,poji), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!