Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mybatis-generator-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mybatis-generator-plugin
Commits
ff418444
Commit
ff418444
authored
Dec 28, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级mybatis-generator到最新版本1.3.6
parent
09c947db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
9 deletions
+95
-9
pom.xml
pom.xml
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/utils/enhanced/TemplateCommentGenerator.java
...ator/plugins/utils/enhanced/TemplateCommentGenerator.java
+88
-3
src/test/java/com/itfsw/mybatis/generator/plugins/tools/AbstractShellCallback.java
...ybatis/generator/plugins/tools/AbstractShellCallback.java
+6
-5
No files found.
pom.xml
View file @
ff418444
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
<dependency>
<dependency>
<groupId>
org.mybatis.generator
</groupId>
<groupId>
org.mybatis.generator
</groupId>
<artifactId>
mybatis-generator-core
</artifactId>
<artifactId>
mybatis-generator-core
</artifactId>
<version>
1.3.
5
</version>
<version>
1.3.
6
</version>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<!-- 日志 -->
<!-- 日志 -->
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/enhanced/TemplateCommentGenerator.java
View file @
ff418444
...
@@ -24,20 +24,23 @@ import org.dom4j.io.SAXReader;
...
@@ -24,20 +24,23 @@ import org.dom4j.io.SAXReader;
import
org.mybatis.generator.api.CommentGenerator
;
import
org.mybatis.generator.api.CommentGenerator
;
import
org.mybatis.generator.api.IntrospectedColumn
;
import
org.mybatis.generator.api.IntrospectedColumn
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.api.MyBatisGenerator
;
import
org.mybatis.generator.api.dom.java.*
;
import
org.mybatis.generator.api.dom.java.*
;
import
org.mybatis.generator.api.dom.xml.TextElement
;
import
org.mybatis.generator.api.dom.xml.TextElement
;
import
org.mybatis.generator.api.dom.xml.XmlElement
;
import
org.mybatis.generator.api.dom.xml.XmlElement
;
import
org.mybatis.generator.config.MergeConstants
;
import
org.mybatis.generator.config.MergeConstants
;
import
org.mybatis.generator.config.PropertyRegistry
;
import
org.mybatis.generator.internal.util.StringUtility
;
import
org.mybatis.generator.internal.util.StringUtility
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
javax.xml.bind.DatatypeConverter
;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.util.
HashMap
;
import
java.util.
*
;
import
java.util.Map
;
import
java.util.Properties
;
import
static
org
.
mybatis
.
generator
.
internal
.
util
.
StringUtility
.
isTrue
;
/**
/**
* ---------------------------------------------------------------------------
* ---------------------------------------------------------------------------
...
@@ -52,6 +55,10 @@ public class TemplateCommentGenerator implements CommentGenerator {
...
@@ -52,6 +55,10 @@ public class TemplateCommentGenerator implements CommentGenerator {
private
Map
<
EnumNode
,
Template
>
templates
=
new
HashMap
<>();
// 模板
private
Map
<
EnumNode
,
Template
>
templates
=
new
HashMap
<>();
// 模板
private
boolean
suppressDate
=
false
;
private
boolean
suppressAllComments
=
false
;
/**
/**
* 构造函数
* 构造函数
* @param templatePath 模板路径
* @param templatePath 模板路径
...
@@ -196,7 +203,11 @@ public class TemplateCommentGenerator implements CommentGenerator {
...
@@ -196,7 +203,11 @@ public class TemplateCommentGenerator implements CommentGenerator {
*/
*/
@Override
@Override
public
void
addConfigurationProperties
(
Properties
properties
)
{
public
void
addConfigurationProperties
(
Properties
properties
)
{
suppressDate
=
isTrue
(
properties
.
getProperty
(
PropertyRegistry
.
COMMENT_GENERATOR_SUPPRESS_DATE
));
suppressAllComments
=
isTrue
(
properties
.
getProperty
(
PropertyRegistry
.
COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS
));
}
}
/**
/**
...
@@ -466,6 +477,80 @@ public class TemplateCommentGenerator implements CommentGenerator {
...
@@ -466,6 +477,80 @@ public class TemplateCommentGenerator implements CommentGenerator {
addXmlElementComment
(
rootElement
,
map
,
EnumNode
.
ADD_ROOT_COMMENT
);
addXmlElementComment
(
rootElement
,
map
,
EnumNode
.
ADD_ROOT_COMMENT
);
}
}
@Override
public
void
addGeneralMethodAnnotation
(
Method
method
,
IntrospectedTable
introspectedTable
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
imports
.
add
(
new
FullyQualifiedJavaType
(
"javax.annotation.Generated"
));
//$NON-NLS-1$
String
comment
=
"Source Table: "
+
introspectedTable
.
getFullyQualifiedTable
().
toString
();
//$NON-NLS-1$
method
.
addAnnotation
(
getGeneratedAnnotation
(
comment
));
}
@Override
public
void
addGeneralMethodAnnotation
(
Method
method
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
imports
.
add
(
new
FullyQualifiedJavaType
(
"javax.annotation.Generated"
));
//$NON-NLS-1$
String
comment
=
"Source field: "
//$NON-NLS-1$
+
introspectedTable
.
getFullyQualifiedTable
().
toString
()
+
"."
//$NON-NLS-1$
+
introspectedColumn
.
getActualColumnName
();
method
.
addAnnotation
(
getGeneratedAnnotation
(
comment
));
}
@Override
public
void
addFieldAnnotation
(
Field
field
,
IntrospectedTable
introspectedTable
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
imports
.
add
(
new
FullyQualifiedJavaType
(
"javax.annotation.Generated"
));
//$NON-NLS-1$
String
comment
=
"Source Table: "
+
introspectedTable
.
getFullyQualifiedTable
().
toString
();
//$NON-NLS-1$
field
.
addAnnotation
(
getGeneratedAnnotation
(
comment
));
}
@Override
public
void
addFieldAnnotation
(
Field
field
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
imports
.
add
(
new
FullyQualifiedJavaType
(
"javax.annotation.Generated"
));
//$NON-NLS-1$
String
comment
=
"Source field: "
//$NON-NLS-1$
+
introspectedTable
.
getFullyQualifiedTable
().
toString
()
+
"."
//$NON-NLS-1$
+
introspectedColumn
.
getActualColumnName
();
field
.
addAnnotation
(
getGeneratedAnnotation
(
comment
));
}
@Override
public
void
addClassAnnotation
(
InnerClass
innerClass
,
IntrospectedTable
introspectedTable
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
imports
.
add
(
new
FullyQualifiedJavaType
(
"javax.annotation.Generated"
));
//$NON-NLS-1$
String
comment
=
"Source Table: "
+
introspectedTable
.
getFullyQualifiedTable
().
toString
();
//$NON-NLS-1$
innerClass
.
addAnnotation
(
getGeneratedAnnotation
(
comment
));
}
private
String
getGeneratedAnnotation
(
String
comment
)
{
StringBuilder
buffer
=
new
StringBuilder
();
buffer
.
append
(
"@Generated("
);
//$NON-NLS-1$
if
(
suppressAllComments
)
{
buffer
.
append
(
'\"'
);
}
else
{
buffer
.
append
(
"value=\""
);
//$NON-NLS-1$
}
buffer
.
append
(
MyBatisGenerator
.
class
.
getName
());
buffer
.
append
(
'\"'
);
if
(!
suppressDate
&&
!
suppressAllComments
)
{
buffer
.
append
(
", date=\""
);
//$NON-NLS-1$
buffer
.
append
(
DatatypeConverter
.
printDateTime
(
Calendar
.
getInstance
()));
buffer
.
append
(
'\"'
);
}
if
(!
suppressAllComments
)
{
buffer
.
append
(
", comments=\""
);
//$NON-NLS-1$
buffer
.
append
(
comment
);
buffer
.
append
(
'\"'
);
}
buffer
.
append
(
')'
);
return
buffer
.
toString
();
}
/**
/**
* 评论模板节点ID
* 评论模板节点ID
*/
*/
...
...
src/test/java/com/itfsw/mybatis/generator/plugins/tools/AbstractShellCallback.java
View file @
ff418444
...
@@ -67,7 +67,6 @@ public abstract class AbstractShellCallback implements ShellCallback {
...
@@ -67,7 +67,6 @@ public abstract class AbstractShellCallback implements ShellCallback {
/**
/**
* 重载项目
* 重载项目
*
* @param sqlSession
* @param sqlSession
* @param loader
* @param loader
* @param packagz
* @param packagz
...
@@ -92,7 +91,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
...
@@ -92,7 +91,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
}
}
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
StringTokenizer
st
=
new
StringTokenizer
(
targetPackage
,
"."
);
StringTokenizer
st
=
new
StringTokenizer
(
targetPackage
,
"."
);
while
(
st
.
hasMoreTokens
())
{
while
(
st
.
hasMoreTokens
())
{
sb
.
append
(
st
.
nextToken
());
sb
.
append
(
st
.
nextToken
());
sb
.
append
(
File
.
separatorChar
);
sb
.
append
(
File
.
separatorChar
);
...
@@ -112,6 +111,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
...
@@ -112,6 +111,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
/* (non-Javadoc)
/* (non-Javadoc)
* @see org.mybatis.generator.api.ShellCallback#isMergeSupported()
* @see org.mybatis.generator.api.ShellCallback#isMergeSupported()
*/
*/
@Override
public
boolean
isMergeSupported
()
{
public
boolean
isMergeSupported
()
{
return
false
;
return
false
;
}
}
...
@@ -119,6 +119,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
...
@@ -119,6 +119,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
/* (non-Javadoc)
/* (non-Javadoc)
* @see org.mybatis.generator.api.ShellCallback#isOverwriteEnabled()
* @see org.mybatis.generator.api.ShellCallback#isOverwriteEnabled()
*/
*/
@Override
public
boolean
isOverwriteEnabled
()
{
public
boolean
isOverwriteEnabled
()
{
return
true
;
return
true
;
}
}
...
@@ -126,9 +127,9 @@ public abstract class AbstractShellCallback implements ShellCallback {
...
@@ -126,9 +127,9 @@ public abstract class AbstractShellCallback implements ShellCallback {
/* (non-Javadoc)
/* (non-Javadoc)
* @see org.mybatis.generator.api.ShellCallback#mergeJavaFile(java.lang.String, java.lang.String, java.lang.String[], java.lang.String)
* @see org.mybatis.generator.api.ShellCallback#mergeJavaFile(java.lang.String, java.lang.String, java.lang.String[], java.lang.String)
*/
*/
public
String
mergeJavaFile
(
String
newFileSource
,
@Override
String
existingFileFullPath
,
String
[]
javadocTags
,
String
fileEncoding
)
public
String
mergeJavaFile
(
String
newFileSource
,
File
existingFile
,
throws
ShellException
{
String
[]
javadocTags
,
String
fileEncoding
)
throws
ShellException
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment