Skip to content

Commit 839562e

Browse files
committed
upload
1 parent c8d3ea3 commit 839562e

136 files changed

Lines changed: 6139 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

javaframework/mybatis/04mybatis的基本使用3/03mybatis框架整合及逆向工厂.md

Lines changed: 774 additions & 0 deletions
Large diffs are not rendered by default.

javaframework/mybatis/04mybatis的基本使用3/mybatis_generator/.idea/compiler.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javaframework/mybatis/04mybatis的基本使用3/mybatis_generator/.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javaframework/mybatis/04mybatis的基本使用3/mybatis_generator/.idea/misc.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javaframework/mybatis/04mybatis的基本使用3/mybatis_generator/.idea/workspace.xml

Lines changed: 522 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE generatorConfiguration PUBLIC
2+
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
3+
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
4+
<!--总配置标签-->
5+
<generatorConfiguration>
6+
<!--具体配置的上下文环境-->
7+
<context id="simple" targetRuntime="MyBatis3DynamicSql">
8+
<!--指向我们需要连接的数据库-->
9+
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
10+
connectionURL="jdbc:mysql://192.168.85.111:3306/demo?serverTimezone=UTC"
11+
userId="root" password="123456"/>
12+
13+
<!--生成对应的实体类
14+
targetPackage:指定存放的包
15+
targetProject:指定当前工程的目录
16+
-->
17+
<javaModelGenerator targetPackage="com.mashibing.bean" targetProject="src/main/java"/>
18+
19+
<!--生成对应的SQL映射文件-->
20+
<!-- <sqlMapGenerator targetPackage="com.mashibing.dao" targetProject="src/main/resources"/>-->
21+
22+
<!--生成对应的DAO接口-->
23+
<javaClientGenerator targetPackage="com.mashibing.dao" targetProject="src/main/java"/>
24+
25+
<!--指定需要反向生成的表-->
26+
<table tableName="emp" />
27+
<table tableName="dept" />
28+
</context>
29+
</generatorConfiguration>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4" />
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.mashibing</groupId>
8+
<artifactId>mybatis_generator</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<dependencies>
11+
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
12+
<dependency>
13+
<groupId>org.mybatis</groupId>
14+
<artifactId>mybatis</artifactId>
15+
<version>3.5.4</version>
16+
</dependency>
17+
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
18+
<dependency>
19+
<groupId>mysql</groupId>
20+
<artifactId>mysql-connector-java</artifactId>
21+
<version>8.0.19</version>
22+
</dependency>
23+
<!-- https://mvnrepository.com/artifact/junit/junit -->
24+
<dependency>
25+
<groupId>junit</groupId>
26+
<artifactId>junit</artifactId>
27+
<version>4.13</version>
28+
<scope>test</scope>
29+
</dependency>
30+
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
31+
<dependency>
32+
<groupId>log4j</groupId>
33+
<artifactId>log4j</artifactId>
34+
<version>1.2.17</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.mybatis.caches</groupId>
38+
<artifactId>mybatis-ehcache</artifactId>
39+
<version>1.2.0</version>
40+
</dependency>
41+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
42+
<dependency>
43+
<groupId>org.slf4j</groupId>
44+
<artifactId>slf4j-api</artifactId>
45+
<version>2.0.0-alpha1</version>
46+
</dependency>
47+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
48+
<dependency>
49+
<groupId>org.slf4j</groupId>
50+
<artifactId>slf4j-log4j12</artifactId>
51+
<version>2.0.0-alpha1</version>
52+
<scope>test</scope>
53+
</dependency>
54+
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
55+
<dependency>
56+
<groupId>org.mybatis.generator</groupId>
57+
<artifactId>mybatis-generator-core</artifactId>
58+
<version>1.4.0</version>
59+
</dependency>
60+
61+
</dependencies>
62+
63+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.mashibing;
2+
3+
import org.mybatis.generator.api.MyBatisGenerator;
4+
import org.mybatis.generator.config.Configuration;
5+
import org.mybatis.generator.config.xml.ConfigurationParser;
6+
import org.mybatis.generator.exception.XMLParserException;
7+
import org.mybatis.generator.internal.DefaultShellCallback;
8+
9+
import java.io.File;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
public class MyTest {
14+
public static void main(String[] args) throws Exception {
15+
List<String> warnings = new ArrayList<String>();
16+
boolean overwrite = true;
17+
File configFile = new File("mbg.xml");
18+
ConfigurationParser cp = new ConfigurationParser(warnings);
19+
Configuration config = cp.parseConfiguration(configFile);
20+
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
21+
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
22+
myBatisGenerator.generate(null);
23+
}
24+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.mashibing.bean;
2+
3+
import javax.annotation.Generated;
4+
5+
public class Dept {
6+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.DEPTNO")
7+
private Integer deptno;
8+
9+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.DNAME")
10+
private String dname;
11+
12+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.LOC")
13+
private String loc;
14+
15+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.DEPTNO")
16+
public Integer getDeptno() {
17+
return deptno;
18+
}
19+
20+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.DEPTNO")
21+
public void setDeptno(Integer deptno) {
22+
this.deptno = deptno;
23+
}
24+
25+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.DNAME")
26+
public String getDname() {
27+
return dname;
28+
}
29+
30+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.DNAME")
31+
public void setDname(String dname) {
32+
this.dname = dname;
33+
}
34+
35+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.937+08:00", comments="Source field: dept.LOC")
36+
public String getLoc() {
37+
return loc;
38+
}
39+
40+
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-03-29T21:11:27.938+08:00", comments="Source field: dept.LOC")
41+
public void setLoc(String loc) {
42+
this.loc = loc;
43+
}
44+
}

0 commit comments

Comments
 (0)