diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/pom.xml b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/pom.xml
index aab5d96..83c6193 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/pom.xml
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/pom.xml
@@ -31,25 +31,19 @@
mysql
mysql-connector-java
-
- ch.qos.logback
- logback-core
-
-
- org.slf4j
- slf4j-api
-
-
- org.apache.maven.plugin-tools
- maven-plugin-annotations
- 3.2
- provided
-
org.apache.maven
maven-plugin-api
- 2.0.6
+ 3.0
+
+
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ 3.4
+ provided
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/db/JdbcConnection.java b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/db/JdbcConnection.java
index d1f4464..92fc51c 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/db/JdbcConnection.java
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/db/JdbcConnection.java
@@ -2,8 +2,6 @@ package com.micro.fast.mybatis.generator.extend.db;
import com.micro.fast.mybatis.generator.extend.util.PropertiesUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -11,7 +9,6 @@ import java.sql.SQLException;
public class JdbcConnection {
- private static final Logger log = LoggerFactory.getLogger(JdbcConnection.class);
private static Connection connection = null;
//加载数据库驱动获取连接
static {
@@ -22,10 +19,8 @@ public class JdbcConnection {
, PropertiesUtil.getProperty("db.username"),
PropertiesUtil.getProperty("db.password"));
} catch (ClassNotFoundException e) {
- log.error("错误{} {}",e,"jdbc驱动加载失败");
e.printStackTrace();
} catch (SQLException e) {
- log.error("错误{} {}",e,"数据库连接失败");
e.printStackTrace();
}
}
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/mojo/MyabtisGeneratorExtendMojo.java b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/mojo/MyabtisGeneratorExtendMojo.java
index db48e1d..982bf95 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/mojo/MyabtisGeneratorExtendMojo.java
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/mojo/MyabtisGeneratorExtendMojo.java
@@ -1,18 +1,28 @@
package com.micro.fast.mybatis.generator.extend.mojo;
-import com.micro.fast.mybatis.generator.extend.service.MybatisGeneratorExtend;
+
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
-/**
- * maven插件执行主类
- */
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
@Mojo(name = "generateFiles")
public class MyabtisGeneratorExtendMojo extends AbstractMojo {
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- MybatisGeneratorExtend.GenerateMybatisGeneratorNeedFilesByTemplates();
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Map pluginContext = getPluginContext();
+ Set set = pluginContext.entrySet();
+ Iterator iterator = set.iterator();
+ while (iterator.hasNext()){
+ Object next = iterator.next();
+ System.out.println("---++++++++++++++++++++"+next);
+ System.out.println(pluginContext.get(next)+"++++++++++++++++++++++++");
}
+
+ }
+
}
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/service/MybatisGeneratorExtend.java b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/service/MybatisGeneratorExtend.java
index 2100eb8..0546d15 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/service/MybatisGeneratorExtend.java
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/service/MybatisGeneratorExtend.java
@@ -5,8 +5,6 @@ import com.micro.fast.mybatis.generator.extend.pojo.Db;
import com.micro.fast.mybatis.generator.extend.pojo.MybatisGenerator;
import com.micro.fast.mybatis.generator.extend.util.FreemarkerUtil;
import com.micro.fast.mybatis.generator.extend.util.PropertiesUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -19,7 +17,6 @@ import java.util.Map;
* mybatis-generate-extend-maven-plugin主要逻辑
*/
public class MybatisGeneratorExtend {
- private static final Logger log = LoggerFactory.getLogger(MybatisGeneratorExtend.class);
private static Db db;
@@ -27,8 +24,14 @@ public class MybatisGeneratorExtend {
//初始化参数
static {
+ if (db==null){
+ db = new Db();
+ }
+ if (mybatisGenerator==null){
+ mybatisGenerator = new MybatisGenerator();
+ }
MybatisGeneratorExtend.db.setDriverLocation(PropertiesUtil.getProperty("db.driverLocation"));
- MybatisGeneratorExtend.db.setUrl(PropertiesUtil.getProperty("db.url"));
+ MybatisGeneratorExtend.db.setUrl(PropertiesUtil.getProperty("db.url").replaceAll("&","&"));
MybatisGeneratorExtend.db.setUsername(PropertiesUtil.getProperty("db.username"));
MybatisGeneratorExtend.db.setPassword(PropertiesUtil.getProperty("db.password"));
MybatisGeneratorExtend.db.setDriverClassName(PropertiesUtil.getProperty("db.driverClassName"));
@@ -57,7 +60,7 @@ public class MybatisGeneratorExtend {
while (resultSet.next()) {
String tableName = resultSet.getString(1);
if (tableName.startsWith(mybatisGenerator.getTablesPrefix())) {
- String doMainObjectName = null;
+ String doMainObjectName = "";
String[] strings = tableName.split("_");
for (String string : strings) {
char c = string.charAt(0);
@@ -77,7 +80,6 @@ public class MybatisGeneratorExtend {
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.ftl", mybatisGeneratorModel, "mybatisGenerator.properties");
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.ftl", mybatisGeneratorModel, "generatorConfig.xml");
} catch (SQLException e) {
- log.error("错误{} {}", e, "sql语句执行失败");
e.printStackTrace();
} finally {
//3.关闭流
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/FreemarkerUtil.java b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/FreemarkerUtil.java
index 20042da..d2484bd 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/FreemarkerUtil.java
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/FreemarkerUtil.java
@@ -1,5 +1,6 @@
package com.micro.fast.mybatis.generator.extend.util;
+import com.micro.fast.mybatis.generator.extend.service.MybatisGeneratorExtend;
import freemarker.core.ParseException;
import freemarker.template.*;
@@ -132,5 +133,6 @@ public class FreemarkerUtil {
System.out.println(System.getProperty("user.dir"));
//5.获取所有的类的jar的加载路径
System.out.println(System.getProperty("java.class.path"));
+ MybatisGeneratorExtend.GenerateMybatisGeneratorNeedFilesByTemplates();
}
}
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/PropertiesUtil.java b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/PropertiesUtil.java
index a7d0921..e22ea56 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/PropertiesUtil.java
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/java/com/micro/fast/mybatis/generator/extend/util/PropertiesUtil.java
@@ -1,13 +1,9 @@
package com.micro.fast.mybatis.generator.extend.util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.*;
import java.util.Properties;
public class PropertiesUtil {
- private static final Logger log = LoggerFactory.getLogger(Properties.class);
private static final String PROPERTIES_PATH = "mybatisStart.properties";
private static Properties properties = null;
static {
@@ -20,7 +16,6 @@ public class PropertiesUtil {
try {
inputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
- log.error("错误{} {}",e,"未找到mybatisStart.properties配置文件");
e.printStackTrace();
}
//3.将输入流写入到properties对象中
@@ -30,7 +25,6 @@ public class PropertiesUtil {
try {
properties.load(inputStream);
} catch (IOException e) {
- log.error("错误{} {}",e,"mybatisStart.properties配置文件失败");
e.printStackTrace();
}
}
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/generatorConfig.xml b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/generatorConfig.xml
new file mode 100644
index 0000000..3af8aaf
--- /dev/null
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/generatorConfig.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisGenerator.properties b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisGenerator.properties
new file mode 100644
index 0000000..93e5c90
--- /dev/null
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisGenerator.properties
@@ -0,0 +1,5 @@
+db.driverLocation=/root/mysql-connector-java-5.1.40-bin.jar
+db.driverClassName=com.mysql.jdbc.Driver
+db.url=jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
+db.username=root
+db.password=studyj2e
\ No newline at end of file
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties
index b56baf4..225a4d2 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/mybatisStart.properties
@@ -1,9 +1,9 @@
-#mybatisGeneratorExtend所需要的参数
-db.driverLocation=
-db.driverClassName=
-db.url=
-db.username=
-db.password=
-mybatisGenerator.pojoPackage=
-mybatisGenerator.daoPackage=
-mybatisGenerator.tablesPrefix=
\ No newline at end of file
+#mybatisGeneratorExtend\u6240\u9700\u8981\u7684\u53C2\u6570
+db.driverLocation=/root/mysql-connector-java-5.1.40-bin.jar
+db.driverClassName=com.mysql.jdbc.Driver
+db.url=jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
+db.username=root
+db.password=studyj2e
+mybatisGenerator.pojoPackage=pojoPackage
+mybatisGenerator.daoPackage=daoPackage
+mybatisGenerator.tablesPrefix=upms
\ No newline at end of file
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/generatorConfig.ftl b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/generatorConfig.ftl
index 66efd10..43dbe90 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/generatorConfig.ftl
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/generatorConfig.ftl
@@ -26,8 +26,8 @@
+ userId="${db.username}"
+ password="${db.password}">
@@ -67,7 +67,7 @@
<#list mybatisGenerator.tablesNameAndDoMainObjectsName?keys as key >
-
+
#list>
\ No newline at end of file
diff --git a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/mybatisGenerator.ftl b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/mybatisGenerator.ftl
index 9a696e6..345dd87 100644
--- a/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/mybatisGenerator.ftl
+++ b/boot-starter/boot-starter-maven-plugin/mybatis-generator-extend-maven-plugin/src/main/resources/templates/mybatisGenerator.ftl
@@ -1,5 +1,5 @@
db.driverLocation=${db.driverLocation}
db.driverClassName=${db.driverClassName}
db.url=${db.url}
-db.username=${db.url}
-db.password=${db.passworld}
\ No newline at end of file
+db.username=${db.username}
+db.password=${db.password}
\ No newline at end of file
diff --git a/ms/upms/pom.xml b/ms/upms/pom.xml
index a5d8182..69465a6 100644
--- a/ms/upms/pom.xml
+++ b/ms/upms/pom.xml
@@ -109,6 +109,11 @@
+
+ com.micro.fast
+ mybatis-generator-extend-maven-plugin
+ ${micro.fast.version}
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/ms/upms/src/main/resources/generatorConfig.xml b/ms/upms/src/main/resources/generatorConfig--.xml
similarity index 100%
rename from ms/upms/src/main/resources/generatorConfig.xml
rename to ms/upms/src/main/resources/generatorConfig--.xml
diff --git a/ms/upms/src/main/resources/mybatisGenerator.properties b/ms/upms/src/main/resources/mybatisGenerator--.properties
similarity index 100%
rename from ms/upms/src/main/resources/mybatisGenerator.properties
rename to ms/upms/src/main/resources/mybatisGenerator--.properties
diff --git a/ms/upms/src/main/resources/mybatisStart.properties b/ms/upms/src/main/resources/mybatisStart.properties
new file mode 100644
index 0000000..225a4d2
--- /dev/null
+++ b/ms/upms/src/main/resources/mybatisStart.properties
@@ -0,0 +1,9 @@
+#mybatisGeneratorExtend\u6240\u9700\u8981\u7684\u53C2\u6570
+db.driverLocation=/root/mysql-connector-java-5.1.40-bin.jar
+db.driverClassName=com.mysql.jdbc.Driver
+db.url=jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
+db.username=root
+db.password=studyj2e
+mybatisGenerator.pojoPackage=pojoPackage
+mybatisGenerator.daoPackage=daoPackage
+mybatisGenerator.tablesPrefix=upms
\ No newline at end of file