entity-修改仓库地址,集成mybatisGenerator
This commit is contained in:
@@ -4,7 +4,7 @@ buildscript {
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
@@ -23,7 +23,7 @@ sourceCompatibility = 1.8
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,3 @@ dependencies {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ sourceCompatibility = 1.8
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ ext {
|
||||
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: "com.arenagod.gradle.MybatisGenerator"
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,31 @@ dependencies {
|
||||
compile group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.3.9'
|
||||
compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
|
||||
compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
|
||||
compile "org.bouncycastle:bcprov-jdk15:1.46"// https://mvnrepository.com/artifact/com.github.xuwei-k/html2image
|
||||
compile "org.bouncycastle:bcprov-jdk15:1.46"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
apply plugin: "com.arenagod.gradle.MybatisGenerator"
|
||||
|
||||
configurations {
|
||||
mybatisGenerator
|
||||
}
|
||||
|
||||
mybatisGenerator {
|
||||
verbose = true
|
||||
configFile = 'src/main/resources/tools/generatorConfig.xml'
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://maven.aliyun.com/repository/gradle-plugin'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath("gradle.plugin.com.arenagod.gradle:mybatis-generator-plugin:1.4")
|
||||
}
|
||||
}
|
||||
106
entity/src/main/resources/tools/generatorConfig.xml
Normal file
106
entity/src/main/resources/tools/generatorConfig.xml
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
<!-- 配置生成器 -->
|
||||
<generatorConfiguration>
|
||||
|
||||
<!--id:必选,上下文id,用于在生成错误时提示-->
|
||||
<context id="mysql" targetRuntime="MyBatis3">
|
||||
|
||||
<!-- 生成的Java文件的编码 -->
|
||||
<property name="javaFileEncoding" value="UTF-8"/>
|
||||
|
||||
<!-- 对注释进行控制 -->
|
||||
<commentGenerator>
|
||||
<!-- suppressDate是去掉生成日期那行注释 -->
|
||||
<property name="suppressDate" value="true"/>
|
||||
<!-- suppressAllComments是去掉所有的注解 -->
|
||||
<property name="suppressAllComments" value="true"/>
|
||||
</commentGenerator>
|
||||
|
||||
<!--jdbc的数据库连接 -->
|
||||
<jdbcConnection
|
||||
driverClass="com.mysql.jdbc.Driver"
|
||||
connectionURL="jdbc:mysql://127.0.0.1:3306/smart_venue"
|
||||
userId="root"
|
||||
password="123456">
|
||||
</jdbcConnection>
|
||||
|
||||
<!-- java类型处理器
|
||||
用于处理DB中的类型到Java中的类型,默认使用JavaTypeResolverDefaultImpl;
|
||||
注意一点,默认会先尝试使用Integer,Long,Short等来对应DECIMAL和 NUMERIC数据类型;
|
||||
-->
|
||||
<javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
|
||||
<!--
|
||||
true:使用BigDecimal对应DECIMAL和 NUMERIC数据类型
|
||||
false:默认,
|
||||
scale>0;length>18:使用BigDecimal;
|
||||
scale=0;length[10,18]:使用Long;
|
||||
scale=0;length[5,9]:使用Integer;
|
||||
scale=0;length<5:使用Short;
|
||||
-->
|
||||
<property name="forceBigDecimals" value="false"/>
|
||||
</javaTypeResolver>
|
||||
|
||||
|
||||
<!-- java模型创建器,是必须要的元素
|
||||
负责:1,key类(见context的defaultModelType);2,java类;3,查询类
|
||||
targetPackage:生成的类要放的包,真实的包受enableSubPackages属性控制;
|
||||
targetProject:目标项目,指定一个存在的目录下,生成的内容会放到指定目录中,如果目录不存在,MBG不会自动建目录
|
||||
-->
|
||||
<javaModelGenerator targetPackage="com.sv.entity" targetProject="src/main/java">
|
||||
<!-- 是否允许子包,即targetPackage.schemaName.tableName -->
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
<!-- 是否对model添加 构造函数 -->
|
||||
<property name="constructorBased" value="true"/>
|
||||
<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
|
||||
<property name="trimStrings" value="true"/>
|
||||
<!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 -->
|
||||
<property name="immutable" value="false"/>
|
||||
</javaModelGenerator>
|
||||
|
||||
<!-- 生成SQL map的XML文件生成器,
|
||||
注意,在Mybatis3之后,我们可以使用mapper.xml文件+Mapper接口(或者不用mapper接口),
|
||||
或者只使用Mapper接口+Annotation,
|
||||
所以,如果 javaClientGenerator配置中配置了需要生成XML的话,这个元素就必须配置
|
||||
targetPackage/targetProject:同javaModelGenerator
|
||||
-->
|
||||
<sqlMapGenerator targetPackage="com.sv.mapper" targetProject="src/main/resources">
|
||||
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</sqlMapGenerator>
|
||||
|
||||
|
||||
<!-- 对于mybatis来说,即生成Mapper接口,注意,如果没有配置该元素,那么默认不会生成Mapper接口
|
||||
targetPackage/targetProject:同javaModelGenerator
|
||||
type:选择怎么生成mapper接口(在MyBatis3/MyBatis3Simple下):
|
||||
1,ANNOTATEDMAPPER:会生成使用Mapper接口+Annotation的方式创建(SQL生成在annotation中),不会生成对应的XML;
|
||||
2,MIXEDMAPPER:使用混合配置,会生成Mapper接口,并适当添加合适的Annotation,但是XML会生成在XML中;
|
||||
3,XMLMAPPER:会生成Mapper接口,接口完全依赖XML;
|
||||
注意,如果context是MyBatis3Simple:只支持ANNOTATEDMAPPER和XMLMAPPER
|
||||
-->
|
||||
<javaClientGenerator targetPackage="mybatis.mapper.sv" type="XMLMAPPER" targetProject="src/main/java">
|
||||
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaClientGenerator>
|
||||
|
||||
<!-- 选择一个table来生成相关文件,可以有一个或多个table,必须要有table元素
|
||||
tableName(必要):要生成对象的表名;
|
||||
domainObjectName 给表对应的 model 起名字
|
||||
注意:大小写敏感问题。
|
||||
-->
|
||||
<table tableName="sv_device" domainObjectName="Device">
|
||||
|
||||
<!--用来修改表中某个列的属性,一个table元素中可以有多个columnOverride元素哈.
|
||||
property属性来指定列要生成的属性名称.
|
||||
-->
|
||||
<!--<columnOverride column="username" property="userName" />-->
|
||||
</table>
|
||||
|
||||
<!--<table tableName="person" domainObjectName="Person"/>-->
|
||||
<!--<table tableName="department" domainObjectName="Depart"/>-->
|
||||
|
||||
</context>
|
||||
|
||||
</generatorConfiguration>
|
||||
@@ -14,7 +14,7 @@ buildscript {
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
@@ -26,7 +26,7 @@ buildscript {
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ buildscript {
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
@@ -25,7 +25,7 @@ buildscript {
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
url 'https://maven.aliyun.com/repository/public'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user