Prechádzať zdrojové kódy

集成生成mybatis相关文件

lcl 1 rok pred
rodič
commit
7d9b4a0f54

+ 12 - 0
pom.xml

@@ -108,6 +108,18 @@
 			<version>0.11.5</version>
 			<scope>runtime</scope>
 		</dependency>
+
+		<dependency>
+			<groupId>org.mybatis.generator</groupId>
+			<artifactId>mybatis-generator-core</artifactId>
+			<version>1.4.0</version>
+		</dependency>
+
+		<dependency>
+            <groupId>org.mybatis.dynamic-sql</groupId>
+            <artifactId>mybatis-dynamic-sql</artifactId>
+            <version>1.1.4</version>
+        </dependency>
 	</dependencies>
 
 	<build>

+ 2 - 0
src/main/java/com/kxs/adminap/controller/TestController.java

@@ -7,6 +7,7 @@ import java.util.Base64;
 import java.util.Dictionary;
 import java.util.List;
 
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -64,6 +65,7 @@ public class TestController {
 
 		// result = new JwtUtil().generateToken("test");
 
+
 		return result;
 	}
 

+ 13 - 6
src/main/resources/generator-configuration.xml

@@ -3,7 +3,9 @@
 
 <generatorConfiguration>
 
-    <context id="KxsMainServer">
+    <classPathEntry location="/Users/lichunlei/MyDisk/JavaProduct/kxs/adminap/src/main/resources/mysql-connector-j-8.0.33.jar" />
+
+    <context id="KxsMainServer" targetRuntime="MyBatis3">
 
         <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
 
@@ -22,20 +24,25 @@
             <property name="forceBigDecimals" value="false" />
         </javaTypeResolver>
 
-        <javaModelGenerator targetPackage="KxsMainServer.model" targetProject="\adminap\src">
+        <javaModelGenerator targetPackage="model.main" targetProject="src/main/java/com/kxs/adminap/">
             <property name="enableSubPackages" value="true" />
-            <property name="trimStrings" value="true" />
         </javaModelGenerator>
 
-        <sqlMapGenerator targetPackage="KxsMainServer.xml" targetProject="\adminap\src">
+        <sqlMapGenerator targetPackage="xml.main" targetProject="src/main/java/com/kxs/adminap/">
             <property name="enableSubPackages" value="true" />
         </sqlMapGenerator>
 
-        <javaClientGenerator type="XMLMAPPER" targetPackage="KxsMainServer.dao" targetProject="\adminap\src">
+        <javaClientGenerator type="XMLMAPPER" targetPackage="dao.main" targetProject="src/main/java/com/kxs/adminap/">
             <property name="enableSubPackages" value="true" />
         </javaClientGenerator>
 
-        <table schema="Users" tableName="Users" domainObjectName="Customer">
+        <table schema="Users" tableName="Users" domainObjectName="Users">
+            <property name="useActualColumnNames" value="true"/>
+            <generatedKey column="ID" sqlStatement="db" identity="true" />
+        </table>
+        <table schema="UserAccount" tableName="UserAccount" domainObjectName="UserAccount">
+            <property name="useActualColumnNames" value="true"/>
+            <generatedKey column="ID" sqlStatement="db" identity="true" />
         </table>
 
     </context>

BIN
src/main/resources/mysql-connector-j-8.0.33.jar