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

做摄影的网站知乎域名怎么选才正确

做摄影的网站知乎,域名怎么选才正确,宁波网站建设与维护,青州市住房和城乡建设局网站之前写过一篇关于springboot 与 mybatis整合的博文#xff0c;使用了一段时间spring-data-jpa#xff0c;发现那种方式真的是太爽了#xff0c;mybatis的xml的映射配置总觉得有点麻烦。接口定义和映射离散在不同的文件中#xff0c;阅读起来不是很方便。于是#xff0c;准… 之前写过一篇关于springboot 与 mybatis整合的博文使用了一段时间spring-data-jpa发现那种方式真的是太爽了mybatis的xml的映射配置总觉得有点麻烦。接口定义和映射离散在不同的文件中阅读起来不是很方便。于是准备使用mybatis的注解方式实现映射。如果喜欢xml方式的可以看我之前的博文Spring boot Mybatis 整合完整版 个人开源项目 springbootmybatisthymeleafdocker构建的个人站点开源项目集成了个人主页、个人作品、个人博客推荐开源项目 开源的springboot接口文档组件swagger2更多干货 SpringBoot系列目录 源码 请前往文章末端查看 开发环境 开发工具Intellij IDEA 2017.1.3JDK : 1.8.0_101spring boot 版本 1.5.8.RELEASEmaven : 3.3.9拓展 springboot 整合 Mybatis 事务管理开始 1.新建一个springboot项目 添加依赖 2.看一下项目结构 3.完整依赖 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.winterchen/groupIdartifactIdspringboot-mybatis-demo2/artifactIdversion0.0.1-SNAPSHOT/versionpackagingjar/packagingnamespringboot-mybatis-demo2/namedescriptionDemo project for Spring Boot/descriptionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion1.5.8.RELEASE/versionrelativePath/ !-- lookup parent from repository --/parentpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncodingjava.version1.8/java.version/propertiesdependenciesdependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion1.3.1/version/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdscoperuntime/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project4.配置文件 因为习惯性的喜欢使用yml作为配置文件所以将application.properties替换为application.yml spring:datasource:url: jdbc:mysql://127.0.0.1:3306/mytestusername: rootpassword: rootdriver-class-name: com.mysql.jdbc.Driver 简单且简洁的完成了基本配置下面看看我们是如何在这个基础下轻松使用Mybatis访问数据库的 使用Mybatis 在Mysql数据库中创建数据表CREATE DATABASE mytest;USE mytest;CREATE TABLE t_user(id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,name VARCHAR(255) NOT NULL ,password VARCHAR(255) NOT NULL ,phone VARCHAR(255) NOT NULL ) ENGINEINNODB AUTO_INCREMENT1000 DEFAULT CHARSETutf8;创建映射对象Userpackage com.winterchen.domain;/*** User实体映射类* Created by Administrator on 2017/11/24.*/public class User {private Integer id;private String name;private String password;private String phone;//省略 get 和 set ... }创建User映射的操作UserMapper为了后续单元测试验证实现插入和查询操作package com.winterchen.mapper;import com.winterchen.domain.User; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select;/*** User映射类* Created by Administrator on 2017/11/24.*/ Mapper public interface UserMapper {Select(SELECT * FROM T_USER WHERE PHONE #{phone})User findUserByPhone(Param(phone) String phone);Insert(INSERT INTO T_USER(NAME, PASSWORD, PHONE) VALUES(#{name}, #{password}, #{phone}))int insert(Param(name) String name, Param(password) String password, Param(phone) String phone);} 如果想了解更多Mybatis注解的详细springboot中使用Mybatis注解配置详解 创建springboot 主类package com.winterchen;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication public class SpringbootMybatisDemo2Application {public static void main(String[] args) {SpringApplication.run(SpringbootMybatisDemo2Application.class, args);} }创建测试单元: 测试逻辑插入一条name为weinterchen的User然后根据user的phone进行查询并判断user的name是否为winterchen。package com.winterchen;import com.winterchen.domain.User; import com.winterchen.mapper.UserMapper; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;RunWith(SpringRunner.class) SpringBootTest public class SpringbootMybatisDemo2ApplicationTests {Autowiredprivate UserMapper userMapper;Testpublic void test(){userMapper.insert(winterchen, 123456, 12345678910);User u userMapper.findUserByPhone(12345678910);Assert.assertEquals(winterchen, u.getName());}}测试结果 说明已经成功了。 **如果出现mapper注入不了的情况请检查版本当前博客的搭建方法只适合1.5.*版本的如果你的版本是2.0以上的版本请参照我的另一篇博客的mybatis的配置springboot2.0整合mybatis ** 事务管理重要 我们在开发企业应用时对于业务人员的一个操作实际是对数据读写的多步操作的结合。由于数据操作在顺序执行的过程中任何一步操作都有可能发生异常异常会导致后续操作无法完成此时由于业务逻辑并未正确的完成之前成功操作数据的并不可靠需要在这种情况下进行回退。 为了测试的成功请把测试的内容进行替换因为之前测试的时候已经将数据生成了重复的数据会对测试的结果有影响 TestTransactionalpublic void test(){userMapper.insert(张三, 123456, 18600000000);int a 1/0;userMapper.insert(李四, 123456, 13500000000);User u userMapper.findUserByPhone(12345678910);Assert.assertEquals(winterchen, u.getName());} 只需要在需要事务管理的方法上添加 Transactional 注解即可然后我们启动测试会发现异常之后数据库中没有产生数据。 如果大家想对springboot事务管理有更加详细的了解欢迎大家查看springboot事务管理详解 源码https://github.com/WinterChenS/springboot-mybatis-demo2/ springboot技术交流群681513531 转载于:https://www.cnblogs.com/winterchens/p/10655558.html
http://www.pierceye.com/news/675608/

相关文章:

  • 杭州网站制作公司网站厦门网站建设 首选猴子网络
  • 公司如何建站合肥网站设计
  • wordpress单页导出wordpress head 优化
  • 建筑模版东莞网站建设技术支持北京网页制作服务商
  • 网站html地图怎么做的wordpress 国内视频网站
  • 哪个网站做的简历比较好龙岗做网站公司icxun
  • 海外网站开发网站打开慢怎么回事
  • 外贸导向企业网站搜索引擎大全排名
  • 网站域名怎么做变更企业查询系统
  • 12306网站多少钱做的怎么研发软件app
  • 手机端建站井冈山保育院网站建设
  • 服装设计网站怎么做wordpress网站商务通
  • 重庆建设医院官方网站医疗网站源码
  • 大学生想做网站天元建设集团有限公司商业承兑汇票拒付最新消息
  • 怎么区分营销型网站文章类型的网站模版
  • 网站充值接口怎么做国家企业官网查询系统
  • 厦门网站建设工程网站备案幕布大小
  • 做家教去什么网站滕州做网站哪家好
  • 深圳市涂能装饰设计公司网站网站建设活动策划方案
  • 建设三合一网站找设计公司上哪个网站
  • 代理ip做网站流量饭店网站模板
  • 保险网站查询软件开发工程师和程序员的区别
  • 江都区城乡建设局网站马局下载app下载安卓免费
  • 网站做后台kuler 网站
  • 北京建网站公司飞沐扬中信息网
  • 商河网站建设公司南县网站建设推荐
  • 湛江企业网站建站模板网站开发 平台
  • c做的网站app开发制作专业吗
  • 杭州做网站公司做网站的文章
  • 那里有制作网站公司做网站需要了解的内容