当前位置: 首页 > news >正文

淮南市谢家集区疫情最新消息seo综合查询怎么用的

淮南市谢家集区疫情最新消息,seo综合查询怎么用的,论网站建设技术的作者是谁,达州网站建设公司目录 一、MyBatis Generator 的使用 1.1、生成类和映射文件 1.1.1、在 pom.xml 中引入依赖 1.1.2、根据 configurationFile 标签中配置的路径 创建 generatorConfig.xml 文件 1.1.3、自动生成类 和 映射文件 1.1.4、在 Insert 标签中添加获取主键值的选项 1.1.5、扫描配置…

目录

一、MyBatis Generator 的使用

1.1、生成类和映射文件

1.1.1、在 pom.xml 中引入依赖

1.1.2、根据 configurationFile 标签中配置的路径 创建 generatorConfig.xml 文件

1.1.3、自动生成类 和 映射文件

1.1.4、在 Insert 标签中添加获取主键值的选项

1.1.5、扫描配置:添加 @Mapper 注解 / 添加扫描注解

1.1.6、配置 mybatis

1.1.7、测试


一、MyBatis Generator 的使用


1.1、生成类和映射文件

1.1.1、在 pom.xml 中引入依赖

在 properties 标签中加入版本号.

<mybatis-generator-plugin-version>1.4.1</mybatis-generator-plugin-version>

在 build => plugins 标签中加入如下配置

            <!-- mybatis ⽣成器插件 --><plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>${mybatis-generator-plugin-version}</version><executions><execution><id>Generate MyBatis Artifacts</id><phase>deploy</phase><goals><goal>generate</goal></goals></execution></executions><!-- 相关配置 --><configuration><!-- 打开⽇志 --><verbose>true</verbose><!-- 允许覆盖 --><overwrite>true</overwrite><!-- 配置⽂件路径 --><configurationFile>src/main/resources/mybatis/generatorConfig.xml</configurationFile></configuration></plugin>

上述配置中需要注意的是 “配置文件路径”,这个路径就是用来生成 实体类和映射文件 配置规则的位置.

1.1.2、根据 configurationFile 标签中配置的路径 创建 generatorConfig.xml 文件

这个文件就是用来描述生成规则的.

根据路径(src/main/resources/mybatis),在 mybatis 目录下创建 generatorConfig.xml 文件.

Ps:下述配置文件中需要修改的有 数据库连接、实体类和映射文件的路径、数据库表名

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfigurationPUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><generatorConfiguration><!-- 驱动包路径,location中路径替换成⾃⼰本地路径 --><classPathEntry location="D:\class\source\mysql-connector-java-5.1.49.jar"/><context id="DB2Tables" targetRuntime="MyBatis3"><!-- 禁⽤⾃动⽣成的注释 --><commentGenerator><property name="suppressAllComments" value="true"/><property name="suppressDate" value="true"/></commentGenerator><!-- 连接配置 --><jdbcConnection driverClass="com.mysql.jdbc.Driver"connectionURL="jdbc:mysql://127.0.0.1:3306/javanav_db?
characterEncoding=utf8&amp;useSSL=false"userId="root"password="1111"></jdbcConnection><javaTypeResolver><!-- ⼩数统⼀转为BigDecimal --><property name="forceBigDecimals" value="false"/></javaTypeResolver><!-- 实体类⽣成位置 --><javaModelGenerator targetPackage="com.example.cyk.model"targetProject="src/main/java"><property name="enableSubPackages" value="true"/><property name="trimStrings" value="true"/></javaModelGenerator><!-- mapper.xml⽣成位置 --><sqlMapGenerator targetPackage="mapper"targetProject="src/main/resources"><property name="enableSubPackages" value="true"/></sqlMapGenerator><!-- mapper 接口⽣成位置 --><javaClientGenerator type="XMLMAPPER"targetPackage="com.example.cyk.mapper" targetProject="src/main/java"><property name="enableSubPackages" value="true"/></javaClientGenerator><!-- 配置⽣成表与实例, 只需要修改表名tableName, 与对应类名domainObjectName 即可--><table tableName="j_article" domainObjectName="Article"enableSelectByExample="false"enableDeleteByExample="false" enableDeleteByPrimaryKey="false"enableCountByExample="false"enableUpdateByExample="false"><!-- 类的属性⽤数据库中的真实字段名做为属性名, 不指定这个属性会⾃动转换 _ 为驼峰命名规则--><property name="useActualColumnNames" value="true"/></table><table tableName="j_article_reply" domainObjectName="ArticleReply"enableSelectByExample="false"enableDeleteByExample="false" enableDeleteByPrimaryKey="false"enableCountByExample="false"enableUpdateByExample="false"><property name="useActualColumnNames" value="true"/></table><table tableName="j_board" domainObjectName="Board"enableSelectByExample="false" enableDeleteByExample="false"enableDeleteByPrimaryKey="false" enableCountByExample="false"enableUpdateByExample="false"><property name="useActualColumnNames" value="true"/></table><table tableName="j_message" domainObjectName="Message"enableSelectByExample="false"enableDeleteByExample="false" enableDeleteByPrimaryKey="false"enableCountByExample="false"enableUpdateByExample="false"><property name="useActualColumnNames" value="true"/></table><table tableName="j_user" domainObjectName="User"enableSelectByExample="false" enableDeleteByExample="false"enableDeleteByPrimaryKey="false" enableCountByExample="false"enableUpdateByExample="false"><property name="useActualColumnNames" value="true"/></table></context>
</generatorConfiguration>

注意:

驱动包路径是自己本地仓库的路径

 

但一定注意!! 需要在非中文的目录下,因此你可以把这个驱动包拷贝出来,放到一个非中文的目录中即可.

1.1.3、自动生成类 和 映射文件

重新加载Maven项⽬,在Plugins节点下出现mybatis-generator,双击运⾏,在对应的目录下⽣成相应的类与映射⽂件:

接着你就可以看到对应的生成了

1.1.4、在 Insert 标签中添加获取主键值的选项

在生成的 xml 文件中,给每一个 insert 标签都添加以下属性:useGeneratedKeys="true" keyProperty="id"

<!-- useGeneratedKeys = true -->
<!-- keyProperty = 主键字段--> <!-- 当插⼊⼀条数据后,可以通过user.getId()获取到⾃动⽣成的Id值,如果⽅法中需要⽴即获取Id值,加⼊这个配置 --> 
<insert id="insert" parameterType="com.example.cyk.model.User" 
useGeneratedKeys="true" keyProperty="id" >

Ps:这个选项也可以自动生成,但是不理想(有些问题)

1.1.5、扫描配置:添加 @Mapper 注解 / 添加扫描注解

有两种方式配置扫描 Mapper 接口.

1)给每个 mapper 包下的 mapper 接口都添加 @Mapper 注解.

2)给启动类上 或者 新建一个配置类(有 @Configuration 注解)加上 @MapperScan("com.example.cyk.mapper") 注解.

1.1.6、配置 mybatis

在 yml 文件中配置

mybatis:mapper-locations: classpath:mapper/**/*Mapper.xml

1.1.7、测试

@SpringBootTest
public class TestMapper {@Autowiredprivate UserMapper userMapper;@Testpublic void select() {User user = userMapper.selectByPrimaryKey(1L);System.out.println(user);}}


 

http://www.yidumall.com/news/18234.html

相关文章:

  • 做网站的图片取材搜索引擎优化的缺点包括
  • 南皮县做网站深圳高端网站建设公司
  • pc网站如何做sp杭州网站排名提升
  • 桂林网站建设找骏程惠州seo外包平台
  • 礼品网站模板李勇seo的博客
  • 莱芜买房网站seo专业培训班
  • 大朗网站建设免费建网站的步骤
  • 网站提高banner图打开速度培训网站推荐
  • soho建网站网站建设计划书
  • 材料网站建设有必要买优化大师会员吗
  • 网站定制开发是什么意思一个品牌的策划方案
  • 合肥网站建设需网站排名优化方案
  • 电销做网站的话术自己在家怎么做跨境电商
  • 做企业网站制作google chrome官网下载
  • 临沂哪里做网站比较好微信推广引流加精准客户
  • 怎么把网站地图上传seo推广优化培训
  • pc端移动端网站开发推广公司有哪些
  • 深圳网站设计美工今日百度小说排行榜
  • 友情链接对网站的影响潮州seo建站
  • 做网站 0元代理网站推广软件下载
  • 翔安区建设局网站疫情防控最新数据
  • 交互性强的网站汕头seo网络推广服务
  • 芜湖做网站郑州网站运营实力乐云seo
  • 做推广哪个食品网站好seo交互论坛
  • 武汉礼品定制公司星巴克seo网络推广
  • 玉溪人民政府网站建设现状万网域名查询官网
  • 销售网站建设实验报告外贸网站免费推广b2b
  • 如何用源码做网站搜索引擎大全网站
  • 沈阳网页设计课学seo需要多久
  • 零售户电商网站订货网址山东最新消息今天