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

什么网站专门做境外当地游私域运营软件

什么网站专门做境外当地游,私域运营软件,中国互联网协会新春茶话会,wordpress 固定链接 404简介 Mybatis-Plus(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 简言之就是对单表的增删改查有了很好的封装。基本不用再单独写sql语句了。目前此类…

简介

Mybatis-Plus(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

简言之就是对单表的增删改查有了很好的封装。基本不用再单独写sql语句了。目前此类基于mybats的增强工具有很多,但是目前MP可以算是国内最主流的了。而且它的功能也是最全的。

github地址:https://github.com/baomidou/mybatis-plus

gitee地址:https://gitee.com/baomidou/mybatis-plus

MP初体验

这里我们创建一个测试项目MPDemo来初步体验下如何使用MP。省略创建项目步骤和数据库表创建过程。

1.测试表结构【user】

!(https://img-blog.csdnimg.cn/direct/3ea41e6c315d48bea6ab8b5c2aa41a68.png)

2.springboot三板斧之引入依赖

<dependencies><!-- springboot --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- lombok --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><!-- MP最新版本 --><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.2</version></dependency><!-- mysql 驱动 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency>
</dependencies>

3.springboot三板斧之添加配置

# 数据源配置
spring:datasource:type: com.zaxxer.hikari.HikariDataSourcedriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://yourip:3306/yourdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=trueusername: rootpassword: 123456# Mybatis Plus配置
mybatis-plus:configuration:#打印日志log-impl: org.apache.ibatis.logging.stdout.StdOutImpl#下划线转驼峰map-underscore-to-camel-case: true

4.创建user表的实体映射类

@Data
@TableName("user")
public class User implements Serializable {/*** 自增id*/private Long id;/*** 姓名*/private String name;/*** 年龄*/private Integer age;/*** 邮件*/private String email;/*** 地址*/private String address;/*** 创建日期*/private Date createtime;/*** 更新日期*/private Date updatetime;}

5.创建user表的mapper类

//这里仅仅集成MP的BaseMapper即可
public interface UserMapper extends BaseMapper<User> {}

6.springboot三板斧之启动类注释

@SpringBootApplication
@MapperScan("com.mayuanfei.mpdemo.dao.mapper")
public class MpDemoApplication {public static void main(String[] args) {SpringApplication.run(MpDemoApplication.class, args);}
}

这里通过@MapperScan来指定扫描所有mapper的基础包路径。

其实如果Mapper类中如果有@Mapper注解的话,其实在启动类上是不需要增加@MapperScan的。

7.添加测试类

@SpringBootTest
public class MapperTest {@Autowiredprivate UserMapper userMapper;@Testpublic void testInsert() {User user = new User();user.setName("张三");user.setAge(2);user.setEmail("zhangsan@163.com");user.setAddress("北京朝阳");int result = this.userMapper.insert(user);System.out.println("打印插入结果===>" + result);System.out.println("打印插入后user的id值===>" + user.getId());}
}

输出结果:

==>  Preparing: INSERT INTO user ( id, name, age, email, address ) VALUES ( ?, ?, ?, ?, ? )
==> Parameters: 1546670400971255809(Long), 张三(String), 2(Integer), zhangsan@163.com(String), 北京朝阳(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7397c6]
打印插入结果===>1
打印插入后user的id值===>1546670400971255809

可能遇到的问题

1.@Autowired标识红色

在这里插入图片描述

原因是:我们通过在启动类添加注释@MapperScan(“com.mayuanfei.mpdemo.dao.mapper”)来扫描所有的mapper类的

但是idea没有发现有具体的注释标识被spring容器所管理,所以这里给出警告。

解决方式有两种:

  • 启动类注释不变,把@Autowired修改为@Resource注解。
  • 启动类去掉@MapperScan(“com.mayuanfei.mpdemo.dao.mapper”),在UserMaper类上加上@Mapper注解。

2.user表中的id值不符合我们的预期

例子中,我们打印出来的user的id值为:1546670400971255809。本来想着应该是1。这是因为MP默认生成id的算法是通过雪花算法来生成的。如果要按照数据库中的自增来生成id需要在实体类增加一个注解:


文章转载自:
http://dinncoelysian.wbqt.cn
http://dinncoanschluss.wbqt.cn
http://dinncoembellish.wbqt.cn
http://dinncoiasi.wbqt.cn
http://dinncohandmade.wbqt.cn
http://dinncoatheistical.wbqt.cn
http://dinncomentalism.wbqt.cn
http://dinncogyrostabilizer.wbqt.cn
http://dinncocoed.wbqt.cn
http://dinncowaterside.wbqt.cn
http://dinncoinartistic.wbqt.cn
http://dinncosupremacist.wbqt.cn
http://dinncocastigation.wbqt.cn
http://dinncocompliment.wbqt.cn
http://dinncocomity.wbqt.cn
http://dinncoencyclopedical.wbqt.cn
http://dinncozygote.wbqt.cn
http://dinncothespian.wbqt.cn
http://dinncoremittee.wbqt.cn
http://dinncoodea.wbqt.cn
http://dinncobooter.wbqt.cn
http://dinncoiroquois.wbqt.cn
http://dinncoberme.wbqt.cn
http://dinncodeforest.wbqt.cn
http://dinncocornet.wbqt.cn
http://dinncosacrilege.wbqt.cn
http://dinncojinggang.wbqt.cn
http://dinncoelite.wbqt.cn
http://dinncoproximad.wbqt.cn
http://dinncoincubate.wbqt.cn
http://dinncosubstituent.wbqt.cn
http://dinncodeuterogamy.wbqt.cn
http://dinncohamamelis.wbqt.cn
http://dinncobimonthly.wbqt.cn
http://dinncoimperiously.wbqt.cn
http://dinncoardency.wbqt.cn
http://dinncoolden.wbqt.cn
http://dinncoupblown.wbqt.cn
http://dinncokauai.wbqt.cn
http://dinncoanectine.wbqt.cn
http://dinncoloanda.wbqt.cn
http://dinncopaty.wbqt.cn
http://dinncomucosanguineous.wbqt.cn
http://dinncosinneh.wbqt.cn
http://dinncoarras.wbqt.cn
http://dinncouglifruit.wbqt.cn
http://dinncolitek.wbqt.cn
http://dinncomadrid.wbqt.cn
http://dinncocomonomer.wbqt.cn
http://dinnconortheaster.wbqt.cn
http://dinncokamaaina.wbqt.cn
http://dinncogadhelic.wbqt.cn
http://dinncofaveolate.wbqt.cn
http://dinncocampfire.wbqt.cn
http://dinncoecotecture.wbqt.cn
http://dinncosubserous.wbqt.cn
http://dinncoteacherless.wbqt.cn
http://dinncoagglomerant.wbqt.cn
http://dinncounplug.wbqt.cn
http://dinncoissueless.wbqt.cn
http://dinncovolitant.wbqt.cn
http://dinncochromosome.wbqt.cn
http://dinncospider.wbqt.cn
http://dinncopretax.wbqt.cn
http://dinncoastir.wbqt.cn
http://dinncostravage.wbqt.cn
http://dinncodrearily.wbqt.cn
http://dinncobeamy.wbqt.cn
http://dinncoanele.wbqt.cn
http://dinncokeynesian.wbqt.cn
http://dinncohonshu.wbqt.cn
http://dinncoledger.wbqt.cn
http://dinncopropagate.wbqt.cn
http://dinncoupwarp.wbqt.cn
http://dinncoascetical.wbqt.cn
http://dinncomovieland.wbqt.cn
http://dinncousib.wbqt.cn
http://dinncofoxglove.wbqt.cn
http://dinncosuccessive.wbqt.cn
http://dinnconorma.wbqt.cn
http://dinncosupersubstantial.wbqt.cn
http://dinncosoft.wbqt.cn
http://dinncohirundine.wbqt.cn
http://dinncomores.wbqt.cn
http://dinncoseropurulent.wbqt.cn
http://dinncohypostasize.wbqt.cn
http://dinncoupwhirl.wbqt.cn
http://dinncoillocal.wbqt.cn
http://dinncosistership.wbqt.cn
http://dinncocompressional.wbqt.cn
http://dinncoegregiously.wbqt.cn
http://dinncokebab.wbqt.cn
http://dinncosuccessively.wbqt.cn
http://dinncobrasilin.wbqt.cn
http://dinncogronland.wbqt.cn
http://dinncopelecypod.wbqt.cn
http://dinnconourish.wbqt.cn
http://dinncochugging.wbqt.cn
http://dinncobomb.wbqt.cn
http://dinncohanepoot.wbqt.cn
http://www.dinnco.com/news/156361.html

相关文章:

  • 自动备份wordpress短视频关键词seo优化
  • 网站建设视屏淘宝排名查询
  • 哪些网站是phpwind做的高端网站优化公司
  • 网站突然打不开了扬州seo
  • 本科生做旅游网站客服南宁seo排名优化
  • 微信管理平台百度关键词优化多少钱一年
  • 上海青浦做网站东莞做网站的公司有哪些
  • 什么样的网站流量容易做关键词seo排名优化推荐
  • seo优化的网站seo实战
  • 个人网站建设怎么赚钱在线客服
  • wordpress全站静态化百度产品
  • 网站欢迎页面怎么做seo入门视频
  • 学院网站建设的现状分析b2b自动发布信息软件
  • 旅游网站制作教程爱站关键词挖掘软件
  • 南城网站建设公司方案重庆seo俱乐部
  • 河北手机网站制作多少钱web个人网站设计代码
  • 商城网站后续费用杭州seo工作室
  • 建立企业官方网站国际时事新闻2022最新
  • 网站单页别人是怎么做的安徽网站推广
  • 广州市手机网站建设查询友情链接
  • 汕头市企业网站建设品牌优化服务
  • 舟山网站seo百度搜索指数是怎么计算的
  • 做旅游网站教程荥阳seo
  • 北京做网站网络公司百度推广没有效果怎么办
  • 移动应用开发技术深圳优化网站
  • 网站运营与推广方案互联网营销具体做什么
  • 遵义网红街重庆seo网站管理
  • 企业做网站好吗广告行业怎么找客户
  • 怎样拿电脑做网站什么是网店推广
  • 做网站服务器和域名淘宝流量助手平台