利用mybatis逆向生成工具生成informix的数据表的 mapper, pojo, example 等类,通过example对象实现对表的增删改查
需要的包
lib包配置mybatis扫描与注解
<!-- 开启注解扫描 -->
<context:component-scan base-package="cn.myccit.ifactory.action.mesview,
cn.myccit.ifactory.mybatis/>
<!-- mybatis数据源配置 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="informixDataSource" />
</bean>
<!-- mybatis mapper 扫描 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.myccit.ifactory.mybatis.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
配置informix数据源
<bean id="informixDataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="driverClassName"><value>${informix.jdbc.driver}</value></property>
<property name="url"><value>${informix.jdbc.connectionURL}</value></property>
<property name="username"><value>${informix.jdbc.username}</value></property>
<property name="password"><value>${informix.jdbc.password}</value></property>
<property name="validationQuery"><value>select count(*) from systables</value></property>
<property name="testWhileIdle" value="true" />
<property name="initialSize"><value>${informix.jdbc.poolsize}</value></property>
<property name="maxActive"><value>${informix.jdbc.maxpoolsize}</value></property>
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="60000"></property>
<property name="minEvictableIdleTimeMillis" value="30000"></property>
</bean>
注意事项
数据库的字段类型的映射
不用schema时
配置详情查看github
https://github.com/mybasket-jack/resource/tree/master/mybatis-generator-informix
网友评论