深圳比较好的ui设计公司,小果seo实战培训课程,设计一个app界面多少钱,怎么修改网站图标前些天发现了一个巨牛的人工智能学习网站#xff0c;通俗易懂#xff0c;风趣幽默#xff0c;忍不住分享一下给大家。点击跳转到教程。
使用mybatis可以逆向生成pojo和mapper文件有很多种方式#xff0c;我以前用的是mybtais自带的generator包来生成#xff0c;连接如下通俗易懂风趣幽默忍不住分享一下给大家。点击跳转到教程。
使用mybatis可以逆向生成pojo和mapper文件有很多种方式我以前用的是mybtais自带的generator包来生成连接如下mybatis自己生成pojo
今天我用了IDEA上使用maven项目来生成pojo和mapper具体步骤如下
1先配置pom.xml文件先配置插件plugin
配置文件如下 buildplugins!-- mybatis逆向工程 --plugingroupIdorg.mybatis.generator/groupIdartifactIdmybatis-generator-maven-plugin/artifactIdversion1.3.2/versionconfiguration!--配置文件的位置--configurationFilesrc/main/resources/Personal-GeneratorConfig.xml/configurationFileverbosetrue/verboseoverwritetrue/overwrite/configuration/plugin/plugins/build
2项目中添加配置文件如上面所示的配置文件目录位置在添加personal-generatorconfig.xml文件然后添加配置文件personal-db.properties位置结构如图所示 其中personal-generator.xml的代码如下
?xml version1.0 encodingUTF-8?
!DOCTYPE generatorConfigurationPUBLIC -//mybatis.org//DTD MyBatis Generator Configuration 1.0//ENhttp://mybatis.org/dtd/mybatis-generator-config_1_0.dtd
generatorConfigurationproperties resourcePersonal-DB.properties/propertiesclassPathEntry location${jdbc.driverLocation} /!--classPathEntry locationD:\zngkpt\m2\repository\mysql\mysql-connector-java\5.1.40\mysql-connector-java-5.1.40.jar /--context idcontext1 targetRuntimeMyBatis3commentGenerator!-- 去除自动生成的注释 --property namesuppressAllComments valuetrue //commentGenerator!-- 数据库连接配置 --jdbcConnection driverClass${jdbc.driverClass}connectionURL${jdbc.connectionURL}userId${jdbc.userId}password${jdbc.password} /!--jdbcConnection driverClasscom.mysql.jdbc.DriverconnectionURLjdbc:mysql://localhost:3306/testuserIdrootpasswordmysql /--!-- 非必需类型处理器在数据库类型和java类型之间的转换控制--javaTypeResolverproperty nameforceBigDecimals valuefalse//javaTypeResolver!--配置生成的实体包targetPackage生成的实体包位置默认存放在src目录下targetProject目标工程名--javaModelGenerator targetPackagecom.unisits.zngkpt.common.userprivrman.pojotargetProjectsrc/main/java /!-- 实体包对应映射文件位置及名称默认存放在src目录下 --sqlMapGenerator targetPackagecom.unisits.zngkpt.common.userprivrman.mapper targetProjectsrc/main/java /!-- 配置表 schema不用填写tableName: 表名enableCountByExample、enableSelectByExample、enableDeleteByExample、enableUpdateByExample、selectByExampleQueryId去除自动生成的例子--table schema tableNamesys_role enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /tabletable schema tableNamesys_permission enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /tabletable schema tableNamesys_role_permission enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /tabletable schema tableNamesys_user enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /tabletable schema tableNamesys_user_role enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /tabletable schema tableNameunit_info enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /tabletable schema tableNameunit_type enableCountByExamplefalse enableSelectByExamplefalseenableDeleteByExamplefalse enableUpdateByExamplefalse selectByExampleQueryIdfalse /table/context
/generatorConfiguration
personal-db.properties的代码如下jdbc.driverLocationD:\\zngkpt\\m2\\repository\\com\\microsoft\\sqlserver\\sqljdbc4\\4.0\\sqljdbc4-4.0.jar
jdbc.driverClasscom.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.connectionURLjdbc:sqlserver://127.0.0.1:1434;DatabaseNamedb_zngkpt
jdbc.userIdsa
jdbc.password123456
3到现在为止所有的mybatis配置工作已经结束了开始配置idea来运行生成pojo吧
点击菜单Run-Edit Configuration,然后在弹出窗体的左上角点击-maven,会出现下面窗体 然后点击apply,确定然后run刚才新建的那个maven即可,最后生成的结构如下 指令为
mybatis-generator:generate -e
转自 https://www.cnblogs.com/ningheshutong/p/6376970.html
另maven 运行命令mvn mybatis-generator:generate