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

centos7怎么做网站服务器优化seo教程

centos7怎么做网站服务器,优化seo教程,jsp网站建设项目,管理系统项目orm框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了, 一个是宣称可以不用写一句SQL的hibernate, 一个是可以灵活调试动态sql的mybatis, 两者各有特点,在企业级系统开发中可以根据需求灵活使用。 发现一个有趣…

orm框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了,
一个是宣称可以不用写一句SQL的hibernate,
一个是可以灵活调试动态sql的mybatis,
两者各有特点,在企业级系统开发中可以根据需求灵活使用。
发现一个有趣的现象:
传统企业大都喜欢使用hibernate,互联网行业通常使用mybatis。

hibernate特点就是所有的sql都用Java代码来生成,不用跳出程序去写(看)sql,有着编程的完整性,
发展到最顶端就是spring data jpa这种模式了,基本上根据方法名就可以生成对应的sql了。

mybatis初期使用比较麻烦,需要各种配置文件、实体类、dao层映射关联、还有一大推其它配置。
当然mybatis也发现了这种弊端,
初期开发了generator可以根据表结果自动生产实体类、配置文件和dao层代码,可以减轻一部分开发量;
后期也进行了大量的优化可以使用注解了,自动管理dao层和配置文件等,发展到最顶端就是今天要讲的这种模式了,
mybatis-spring-boot-starter就是springboot+mybatis可以完全注解不用配置文件,也可以简单配置轻松上手。

参考:

springboot-mybatis多数据源的两种整合方法

springboot(六):如何优雅的使用mybatis

springboot(七):springboot+mybatis多数据源最简解决方案

springboot(五):spring data jpa的使用

springboot(十五):springboot+jpa+thymeleaf增删改查示例

一、mybatis常见库:

MyBatis Generator (MBG)

自动生成dao类mapper,mapper.xml和对应数据库字段的entity实体类

mybatis/generator

PageHelper

用于分页

pagehelper/Mybatis-PageHelper

通用mapper,

极其方便的使用MyBatis单表的增删改查

abel533/Mapper

MyBatis-Plus(MP)

是一个 MyBatis 的增强工具,

在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

baomidou/mybatis-plus

二、mybatis集成demo:

原生mybatis可以使用xml,也可注解形式来操作数据库。

原生:

xml方式原生mybatis

注解方式原生mybatis

原生mybatis(注解)多数据源

原生mybatis(xml)多数据源

库的使用:

MyBatis Generator的使用

mybatis-generator + 通用Mapper的使用

MyBatis-Plus的使用

其他:关于jpa的demo:

spring data jpa

三、mybatis常见问题:

问题一:

org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'com.example.demo.DemoApplicationTests': 
Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type 'com.example.demo.dao.UserMapper' available: 
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Autowired(required=true)}

原因:找不到mapper的Java文件,缺少@Mapper或者@MapperScan(“Mapper包名”),添加即可,如下:

@Mapper
public interface UserMapper {int deleteByPrimaryKey(Integer id);int insert(User record);User selectByPrimaryKey(Integer id);List<User> selectAll();int updateByPrimaryKey(User record);
}

@SpringBootApplication
@MapperScan("com.example.demo.mapper")
public class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}}

注意:只要有mapper的Java文件就需要配置。

问题二:

org.apache.ibatis.binding.BindingException: 
Invalid bound statement (not found): com.example.demo.dao.UserMapper.selectByPrimaryKey//或org.apache.ibatis.binding.BindingException: 
Invalid bound statement (not found): com.example.demo.dao.BookDao.getAll

原因:找不到mapper的xml文件,【缺少】以下配置或者【路径错误】:

# mapper
mybatis.mapper-locations=classpath:mapper/*.xml

注意:只要有mapper的xml文件就需要配置。

问题三

java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

数据库配置需要添加时区:&serverTimezone=GMT,如下:

# database
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT
spring.datasource.username=root
spring.datasource.password=admin
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

问题四

### Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: 
Data truncation: Out of range value for column 'id' at row 1
; Data truncation: Out of range value for column 'id' at row 1; 
nested exception is com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: 
Data truncation: Out of range value for column 'id' at row 1] with root cause

将字段的类型由int转为BIGINT,如下:

ALTER TABLE user MODIFY id BIGINT(20) AUTO_INCREMENT;
http://www.lbrq.cn/news/2675737.html

相关文章:

  • 定制型网站建设服务网站制作400哪家好
  • 巩义做网站优化免费软文网站
  • 旅游网网站建设设计网站的公司
  • 景安网站备案要多久兰州网络推广关键词优化
  • 网站轮播效果怎么做百度首页排名优化平台
  • 安溪学校网站建设百合seo培训
  • 在线做头像的网站今日腾讯新闻最新消息
  • 网站怎么做更新seo 最新
  • 福建建设注册中心网站软文代写自助发稿平台
  • 长沙营销型网站建设制作大学生网络营销策划书
  • 西宁做手机网站的公司唐山百度seo公司
  • 做dw网站图片怎么下载九易建网站的建站流程
  • 企业官网设计现状seo在线培训课程
  • 贵阳网站排名优化免费广告投放网站
  • 南京便宜网站建设中文域名交易网站
  • 网络优化网站建设学习随州网络推广
  • 三年片在线观看免费大全爱奇艺长沙seo外包服务
  • 房地产市场信息系统网站长沙疫情最新情况
  • 深圳网络推广外包公司好的seo平台
  • 江西建站哪家专业傻瓜式自助建站系统
  • 增城做网站公司今晚比赛预测比分
  • 网站栏目怎么做网站流量统计
  • 做网站温州优秀品牌策划方案
  • 电话网站模版2022近期时事热点素材摘抄
  • 做网站都要掌握什么西安网站搭建
  • soho的网站怎么做深圳头条新闻
  • 黄山旅游攻略四日游钱排名优化怎么做
  • 海淘科技上海网站设计网站赚钱
  • 做外贸网站商城引擎优化seo怎么做
  • 北京网站外包公司软文营销的特点有哪些
  • Redis 01 数据结构
  • 论文学习22:UNETR: Transformers for 3D Medical Image Segmentation
  • 算法训练营DAY57 第十一章:图论part07
  • 基于SpringBoot+Uniapp的血压监控小程序(Echarts图形化分析)
  • special topic 8 (2) and topic 9 (1)
  • 旅行者1号无线电工作频段