当前位置:网站首页>Code generator - single table query crud - generator
Code generator - single table query crud - generator
2022-07-03 05:51:00 【SSID-cc-r】
(1) Introduce dependencies
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.4.0</version>
</dependency>
(2)generator You have to configure the file — It must be placed under the project
(3)generato.xml
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- Generation of comments -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- Database connection information -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/mybatis?serverTimezone=Asia/Shanghai"
userId="root"
password="123456">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- The package where the generated entity class is located -->
<javaModelGenerator targetPackage="com.ccr.entity" targetProject="./src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- The mapping file exists in the directory -->
<sqlMapGenerator targetPackage="mapper" targetProject="./src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!--dao The package where the interface is located -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.ccr.dao" targetProject="./src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- surface
schema: The database where the table is located
tableName: Table name
domainObjectName: Name of entity class
-->
<table schema="mybatis" tableName="tbl_emp" domainObjectName="Emp"
enableDeleteByExample="false"
enableSelectByExample="false"
enableUpdateByExample="false"
enableCountByExample="false"/>
<table schema="mybatis" tableName="tbl_dept" domainObjectName="Dept"
enableDeleteByExample="false"
enableSelectByExample="false"
enableUpdateByExample="false"
enableCountByExample="false"/>
</context>
(4) Test code public void Test01() throws Exception{
List warnings = new ArrayList();
boolean overwrite = true;
File configFile = new File(“geberator.xml”);
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
}
边栏推荐
- 2022.6.30DAY591
- [teacher Zhao Yuqiang] index in mongodb (Part 2)
- How do I migrate my altaro VM backup configuration to another machine?
- Source insight operation manual installation trial
- Together, Shangshui Shuo series] day 9
- Life is a process of continuous learning
- Error 1045 (28000) occurs when Linux logs in MySQL: access denied for user 'root' @ 'localhost' (using password: yes)
- [teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
- chromedriver对应版本下载
- 理解 期望(均值/估计值)和方差
猜你喜欢
Configure DTD of XML file
[branch and cycle] | | super long detailed explanation + code analysis + a trick game
redis 无法远程连接问题。
[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis
Deep learning, thinking from one dimensional input to multi-dimensional feature input
[Zhao Yuqiang] deploy kubernetes cluster with binary package
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)
Linux登录MySQL出现ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
Altaro o365 total backup subscription plan
随机推荐
Deep learning, thinking from one dimensional input to multi-dimensional feature input
How to use source insight
Redis cannot connect remotely.
【无标题】
CAD插件的安装和自动加载dll、arx
Btrfs and ext4 - features, strengths and weaknesses
Together, Shangshui Shuo series] day 9
[teacher Zhao Yuqiang] use the catalog database of Oracle
Final review (Day7)
How to create your own repository for software packages on Debian
2022.7.2day594
期末复习DAY8
期末复习(Day5)
[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis
CAD插件的安裝和自動加載dll、arx
2022.6.30DAY591
[teacher Zhao Yuqiang] index in mongodb (Part 2)
Source insight operation manual installation trial
Apache+PHP+MySQL环境搭建超详细!!!
MySQL 5.7.32-winx64 installation tutorial (support installing multiple MySQL services on one host)