コマンド:
MVN MyBatisの発電機:生成
プロジェクト構造:
内容のgeneratorConfig.xml例
<?のXmlバージョン= "1.0"エンコード= "UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC " - // mybatis.org//DTD設定MyBatisのジェネレータ1.0 // EN" 「http://mybatis.org/dtd "/mybatis-generator-config_1_0.dtd > < generatorConfiguration > < コンテキストID =" mysqlgenerator " targetRuntime =" MyBatisの3 " > < プロパティ名=" autoDelimitKeywords " 値をtrueに=を" " /> <! - 使用することができる` fields`を含めます名前、予約語SQLエラーと回避の競合にフィールド名- > <プロパティ名=「beginningDelimiter」値= "`" /> < プロパティ名= "endingDelimiter " 値=" '" /> <! - 自動生成のtoStringメソッド- > < プラグインタイプ= "org.mybatis.generator.plugins.ToStringPlugin" /> <! - 自動生成方法及びハッシュコードメソッドEquals > - < プラグインタイプ= "org.mybatis.generator.plugins.EqualsHashCodePlugin" /> <! - 非公式プラグhttps://github.com/itfsw/mybatis-generator-プラグイン- > <! - クエリ単一のデータ・プラグイン- > < プラグインタイプの=「com.itfsw.mybatis。generator.plugins.SelectOneByExamplePlugin」 /> <! - クエリを選択プラグに返される結果- > < プラグインタイプの= "com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin" /> <! - 実施例の基準強化プラグ- > < プラグインタイプの=「COM。 itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin " /> <! - ウィジェット得るために、対応するデータモデル列の属性- > < プラグインタイプ=" com.itfsw.mybatis.generator.plugins.ModelColumnPluginを" /> <! - ロジックプラグインを削除する- > < プラグインタイプの= "com.itfsw.mybatis.generator.plugins.LogicalDeletePlugin" > <!- ここで、グローバル設定値を覆うテーブルに配置されたコースの列と墓石を、滴下グローバル論理値を構成- > <! - 論理削除列タイプは、数、ストリング、またはブール型、データベースを使用することができますTINYINT(1)- > < プロパティ名を= "logicalDeleteColumn" 値は= "削除" /> !- < 墓石-削除された値- > < プロパティ名= "logicalDeleteValue" 値=」1" /> <を! - 墓石-削除された値- > < プロパティ名= "logicalUnDeleteValue" 値= "0" /> </ プラグイン> < commentGenerator > < プロパティ名= "suppressDate" 値= "true"を/> <! - <プロパティ名= "suppressAllComments"値= "true"を/> - > </ commentGenerator > <! - 数据库连接信息- > < JDBCConnectionのdriverClass = "はcom.mysql.jdbc.Driver" connectionURL = "はjdbc:mysqlの://192.168.1.100:?3306 / theorydance useUnicode =真&#038; characterEncoding = UTF-8&#038; serverTimezone = UTC&#038; verifyServerCertificate = falseを&#038; useSslオプション= false"に はuserId = "ルート" パスワード= "123456" /> < javaTypeResolver > <プロパティ名= "useJSR310Types" 値= "true"を/> </ javaTypeResolver > < javaModelGenerator targetPackage = "demo.theorydance.db.domain" targetProject = "SRC /メイン/ジャワ" /> < sqlMapGenerator targetPackage = "demo.theorydance。 db.dao」targetProject = "SRC /メイン/リソース" /> < javaClientGeneratorのタイプ= "XMLMAPPER" targetPackage = "demo.theorydance.db.dao" targetProject = "SRC /メイン/ジャワ"/> <! - テーブル名- > < 表tableNameの= "学生" > </ テーブル> </ コンテキスト> </ generatorConfiguration >
プラグインを追加するのpom.xml
< ビルド> < プラグイン> < プラグイン> < のgroupId > org.mybatis.generator </ のgroupId > < たartifactId > MyBatisの発電-達人-プラグイン</ たartifactId > < バージョン> 1.3.7 </ バージョン> < 構成> < configurationFile > MyBatisの発電機/ generatorConfig.xml </ configurationFile > < 上書き>真</ 上書き> < 冗長>真</ 冗長> </ 設定> < 依存性> < 依存> < groupIdを> mysqlの</ groupIdを> < たartifactId >のmysql-コネクタ-javaの</ たartifactId > < バージョン> 5.1.46 </ バージョン> </ 依存関係> < 依存> <groupId >com.itfsw </ groupIdを> < たartifactId > MyBatisの発電・プラグイン</ たartifactId > < バージョン> 1.2.12 </ バージョン> </ 依存関係> </ 依存関係> </ プラグイン> </ プラグイン> </ ビルド>