Commit 4b099408 authored by 胡小根's avatar 胡小根

可以成功生成一个表的dao/mapper等

parent 231c3598
package com.haomostudio.SpringMVCProjectTemplate;
import com.haomostudio.SpringMVCProjectTemplate.CrmUser;
import com.haomostudio.SpringMVCProjectTemplate.CrmUserExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface CrmUserMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
long countByExample(CrmUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int deleteByExample(CrmUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int deleteByPrimaryKey(String id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int insert(CrmUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int insertSelective(CrmUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
List<CrmUser> selectByExample(CrmUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
CrmUser selectByPrimaryKey(String id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int updateByExampleSelective(@Param("record") CrmUser record, @Param("example") CrmUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int updateByExample(@Param("record") CrmUser record, @Param("example") CrmUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int updateByPrimaryKeySelective(CrmUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CRM_USER
*
* @mbg.generated Thu Oct 06 17:59:41 CST 2016
*/
int updateByPrimaryKey(CrmUser record);
}
\ No newline at end of file
# MyBatis Generator
采用MyBatis Generator自动生成以下代码:
mapper.xml
mapper.java
domain.java
运行如下命令:
mvn mybatis-generator:generate -pl web # 注意: 只需要执行子目录web的配置文件就可以了
\ No newline at end of file
......@@ -453,15 +453,6 @@
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<configurationFile>${project.basedir}/web/src/main/resources/config/mysqlGeneratorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
<jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver>
<jdbcURL>jdbc:mysql://127.0.0.1:3306/zhuluoxi</jdbcURL>
<jdbcUserId>root</jdbcUserId>
<jdbcPassword>123456</jdbcPassword>
</configuration>
</plugin>
</plugins>
</pluginManagement>
......@@ -472,7 +463,7 @@
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<configurationFile>${project.basedir}/web/src/main/resources/config/mysqlGeneratorConfig.xml</configurationFile>
<configurationFile>${basedir}/src/main/resources/mybatis/oracleGeneratorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
......
<?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>
<classPathEntry location="/Users/hxgqh/.m2/repository/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar" />
<context id="testTables" targetRuntime="MyBatis3">
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@bcs.hitevision.com:1521:crmd02"
userId="crm"
password="sohu2020"/>
<!-- 指定生成的类型为java类型,避免数据库中number等类型字段 -->
<javaTypeResolver>
<property name="forceBigDecimals"
value="false"/>
</javaTypeResolver>
<!-- 生成model模型,对应的包,存放位置可以指定具体的路径,如/ProjectName/src,也可以使用MAVEN来自动生成 -->
<javaModelGenerator targetPackage="com.haomostudio.model"
targetProject="\domain\src">
<property name="enableSubPackages"
value="true"/>
</javaModelGenerator>
<!--对应的xml mapper文件 -->
<sqlMapGenerator targetPackage="com.haomostudio.dao"
targetProject="\web\src\main\resources\mybatis">
<property name="enableSubPackages"
value="true"/>
</sqlMapGenerator>
<!-- 对应的dao接口 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.jacksoft.mybatis.generator.dao"
targetProject="\dao\src">
<property name="enableSubPackages"
value="true"/>
</javaClientGenerator>
<table tableName="user"
domainObjectName="User"/>
</context>
</generatorConfiguration>
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/crm_dev?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull
jdbc.username=root
jdbc.password=123456
\ No newline at end of file
#jdbc.driverClassName=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://127.0.0.1:3306/crm_dev?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull
#jdbc.username=root
#jdbc.password=123456
\ No newline at end of file
#mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.28.163.192:3306/smartchatNew?useUnicode=true&amp;characterEncoding=UTF-8
jdbc.username=knowledge
jdbc.password=knowledge
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://10.28.163.192:3306/smartchatNew?useUnicode=true&amp;characterEncoding=UTF-8
#jdbc.username=knowledge
#jdbc.password=knowledge
#connection pool settings
jdbc.pool.maxIdle=10
......
......@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry location="/Users/hxgqh/.m2/repository/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar" />
<classPathEntry location="/Users/hxgqh/.m2/repository/com/oracle/ojdbc6/11.2.0.1.0/ojdbc6-11.2.0.1.0.jar" />
<context id="testTables" targetRuntime="MyBatis3">
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
......@@ -19,29 +19,28 @@
</javaTypeResolver>
<!-- 生成model模型,对应的包,存放位置可以指定具体的路径,如/ProjectName/src,也可以使用MAVEN来自动生成 -->
<javaModelGenerator targetPackage="com.haomostudio.model"
targetProject="\domain\src">
<javaModelGenerator targetPackage="com.haomostudio.SpringMVCProjectTemplate"
targetProject="domain/src/main/java/">
<property name="enableSubPackages"
value="true"/>
value="false"/>
</javaModelGenerator>
<!--对应的xml mapper文件 -->
<sqlMapGenerator targetPackage="com.haomostudio.dao"
targetProject="\web\src\main\resources\mybatis">
<sqlMapGenerator targetPackage="com.haomostudio.SpringMVCProjectTemplate"
targetProject="web/src/main/resources/mybatis/">
<property name="enableSubPackages"
value="true"/>
</sqlMapGenerator>
<!-- 对应的dao接口 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.jacksoft.mybatis.generator.dao"
targetProject="\dao\src">
targetPackage="com.haomostudio.SpringMVCProjectTemplate"
targetProject="dao/src/main/java/">
<property name="enableSubPackages"
value="true"/>
value="false"/>
</javaClientGenerator>
<table tableName="user"
domainObjectName="User"/>
<table tableName="crm_user"
domainObjectName="CrmUser"/>
</context>
</generatorConfiguration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment