Intellij Idea 版本:2019.3.2
1.新建Maven项目,选择 maven-archetype-webapp
2.填写name,groupId和ArtifactId等信息
3.配置Maven路径,这里不在赘述。
4.在/src/main文件下新建java和resources文件夹,并且通过Mark Directory As 将java文件夹设置成Sources Root,将resources文件夹设置成Resources Root。
5.pom.xml配置
4.0.0
org.example
mybatis-generator-demo
1.0-SNAPSHOT
war
mybatis-generator-demo Maven Webapp
http://www.example.com
UTF-8
1.7
1.7
junit
junit
4.11
test
com.oracle
ojdbc6
11.2.0.1.0
mybatis-generator-demo
maven-clean-plugin
3.1.0
maven-resources-plugin
3.0.2
maven-compiler-plugin
3.8.0
maven-surefire-plugin
2.22.1
maven-war-plugin
3.2.2
maven-install-plugin
2.5.2
maven-deploy-plugin
2.8.2
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.6
src/main/resources/mybatis-generator/generatorConfig.xml
true
true
Generate MyBatis Artifacts
generate
generate-sources
com.oracle
ojdbc6
11.2.0.1.0
6.resources文件夹下新建 mapper和mybatis-generator文件夹,在mybatis-generator文件夹下新建generator.properties和generatorConfig.xml。
generator.properties[1]
jdbc.driverClass=oracle.jdbc.driver.OracleDriver
jdbc.connectionURL=jdbc:oracle:thin:@ip:1521:orcl
jdbc.username=用户名
jdbc.password=密码
generatorConfig.xml[1]
7.执行代码,填写Name和Command line信息,其中Command line输入“mybatis-generator:generate -e”。
8.执行run即可生成相应代码。
注:maven 项目添加 pom 的 oracle 依赖可参考:http://www.mamicode.com/info-detail-2413120.html。
参考文章:
1.https://blog.csdn.net/zanguaihong8955/article/details/90210586
2.https://www.jb51.net/article/131020.htm
3.http://www.mamicode.com/info-detail-2413120.html