标签:dbcc -o rate enable asi callback oid lock package
①. 把plugins中的所有jar拷贝到eclipse的plugins文件夹之中, 把features中的所有文件夹拷贝到eclipse的features文件夹之中,重启eclipse,ok
<?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:数据库的JDBC驱动的jar包地址 -->
<classPathEntry
location="G:\mysql-connector-java-5.1.7-bin.jar" />
<context id="caigouTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="false" />
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<!-- <jdbcConnection driverClass="oracle.jdbc.OracleDriver"
connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:yycg"
userId="yycg"
password="yycg">
</jdbcConnection> -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/crm"
userId="root"
password="123">
</jdbcConnection>
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和
NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置 -->
<javaModelGenerator targetPackage="com.heima.domain"
targetProject="crm_ssm">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- targetProject:自动mapper的位置 -->
<sqlMapGenerator targetPackage="com.heima.mapper"
targetProject="crm_ssm">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.heima.mapper" implementationPackage="com.heima.mapper"
targetProject="crm_ssm">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="base_dict" ></table>
<table tableName="customer" ></table>
<!-- <table schema="" tableName="userjd" />
<table schema="" tableName="usergys" />
<table schema="" tableName="dictinfo" />
<table schema="" tableName="dicttype" />
<table schema="" tableName="basicinfo" /> -->
</context>
</generatorConfiguration>
按照之前插件逆向工程那样的修改,但是targetProject应该都等于".\src"
<?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:数据库的JDBC驱动的jar包地址 -->
<classPathEntry
location="G:\mysql-connector-java-5.1.7-bin.jar" />
<context id="caigouTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="false" />
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<!-- <jdbcConnection driverClass="oracle.jdbc.OracleDriver"
connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:yycg"
userId="yycg"
password="yycg">
</jdbcConnection> -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/crm"
userId="root"
password="123">
</jdbcConnection>
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和
NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置 -->
<javaModelGenerator targetPackage="com.heima.domain"
targetProject=".\src">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- targetProject:自动mapper的位置 -->
<sqlMapGenerator targetPackage="com.heima.mapper"
targetProject=".\src">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.heima.mapper" implementationPackage="com.heima.mapper"
targetProject=".\src">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="base_dict" ></table>
<table tableName="customer" ></table>
<!-- <table schema="" tableName="userjd" />
<table schema="" tableName="usergys" />
<table schema="" tableName="dictinfo" />
<table schema="" tableName="dicttype" />
<table schema="" tableName="basicinfo" /> -->
</context>
</generatorConfiguration>
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;
public class SqlSGen {
public static void main(String[] args) throws Exception {
SqlSGen();
}
private static void SqlSGen() throws Exception {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File("src/generatorConfig-base.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,
callback, warnings);
myBatisGenerator.generate(null);
}
}
@Controller
public class CustomerController {
@Autowired
private BaseDictService baseDictService;
@Autowired
private CustomerService customerService;
//客户来源类别码
@Value("${CUST_SOURCE}")
private String CUST_SOURCE;
//客户行业类别码
@Value("${CUST_INDUSTRY}")
private String CUST_INDUSTRY;
//客户级别类别码
@Value("${CUST_LEVEL}")
private String CUST_LEVEL;
/**
* 跳转显示页面
* @return
*/
@RequestMapping("list")
public String list(Model model){
//客户来源
List<BaseDict> sourceList= baseDictService.findBaseDictWithTypeCode(CUST_SOURCE);
model.addAttribute("fromType", sourceList);
//客户行业
List<BaseDict> industryList= baseDictService.findBaseDictWithTypeCode(CUST_INDUSTRY);
model.addAttribute("industryType", industryList);
//客户级别
List<BaseDict> levelList= baseDictService.findBaseDictWithTypeCode(CUST_LEVEL);
model.addAttribute("levelType", levelList);
return "list";
}
}
@Autowired
private BaseDictMapper baseDictMapper;
/**
* 需求:根据类别码查询类别
* 参数:String typeCode
* 返回值:List<BaseDict>
*/
public List<BaseDict> findBaseDictWithTypeCode(String typeCode) {
// 创建example对象
BaseDictExample example = new BaseDictExample();
//创建criteria对象
//createCriteria是一个list集合,封装查询条件
//where id=3 AND username like ‘‘ and sex=男
//createCriteria.andIdEqualTo(id) === id=3
//createCriteria.andUsernameLike(username) === username like ‘‘
//xml文件使用foreach循环条件,变成一个sql语句
Criteria createCriteria = example.createCriteria();
//设置查询参数 根据类别码查询类别
createCriteria.andDictTypeCodeEqualTo(typeCode);
//执行查询
List<BaseDict> baseList = baseDictMapper.selectByExample(example);
return baseList;
}
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml,classpath:applicationContext-*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
标签:dbcc -o rate enable asi callback oid lock package
原文地址:http://www.cnblogs.com/qinhelili/p/6985958.html