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

通付盾 网站建设公司专门的网页制作工具有

通付盾 网站建设公司,专门的网页制作工具有,wordpress广告,大连网站开发建MyBatis简介 MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache 迁移到了google code#xff0c;并且改名为MyBatis 。 集成spring boot 的时候必须在mapper接口上面标注Mapper注解 项目图片 pom.xml 只需要在pom.xml引入需要的数据库配置#xff0c;就会…MyBatis简介 MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache 迁移到了google code并且改名为MyBatis 。 集成spring boot 的时候必须在mapper接口上面标注Mapper注解 项目图片 pom.xml 只需要在pom.xml引入需要的数据库配置就会自动访问此数据库如果需要配置其他数据库可以在application.properties进行添加 默认使用org.apache.tomcat.jdbc.pool.DataSource创建连接池 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.jege.spring.boot/groupIdartifactIdspring-boot-mybatis/artifactIdversion0.0.1-SNAPSHOT/versionpackagingjar/packagingnamespring-boot-mybatis/nameurlhttp://maven.apache.org/url!-- 公共spring-boot配置下面依赖jar文件不用在写版本号 --parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion1.4.1.RELEASE/versionrelativePath //parentpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingjava.version1.8/java.version/propertiesdependencies!-- 持久层 --dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion1.1.1/version/dependency!-- h2内存数据库 --dependencygroupIdcom.h2database/groupIdartifactIdh2/artifactIdscoperuntime/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency/dependenciesbuildfinalNamespring-boot-mybatis/finalNamepluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdconfigurationsource${java.version}/sourcetarget${java.version}/target/configuration/plugin/plugins/build /project模型对象User package com.jege.spring.boot.mybatis.entity;/*** 模型对象*/ public class User {private Long id;private String name;private Integer age;public User() {}public User(String name, Integer age) {this.name name;this.age age;} }持久层UserMapper package com.jege.spring.boot.mybatis.mapper;import java.util.List;import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select;import com.jege.spring.boot.mybatis.entity.User;/*** 持久层接口由spring自动生成其实现*/ Mapper public interface UserMapper {Delete(drop table t_user if exists)void dropTable();Insert(create table t_user (id bigint generated by default as identity, age integer, name varchar(255), primary key (id)))void createTable();Insert(insert into t_user(name,age) values(#{name},#{age}))void insert(User user);Select(select id,name,age from t_user)ListUser findAll();Select(select id,name,age from t_user where name like #{name})ListUser findByNameLike(String name);Delete(delete from t_user)void deleteAll();} 无需application.properties 测试类UserMapperTest package com.jege.spring.boot.mybatis;import static org.assertj.core.api.Assertions.assertThat;import org.junit.After; import org.junit.Before; 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.SpringJUnit4ClassRunner;import com.jege.spring.boot.mybatis.entity.User; import com.jege.spring.boot.mybatis.mapper.UserMapper;RunWith(SpringJUnit4ClassRunner.class) SpringBootTest() public class UserMapperTest {AutowiredUserMapper userMapper;// 每次执行Test之前先删除表创建表Beforepublic void before() throws Exception {userMapper.dropTable();userMapper.createTable();}// 打印出class com.sun.proxy.$Proxy66表示spring注入通过jdk动态代理获取接口的子类Testpublic void proxy() throws Exception {System.out.println(userMapper.getClass());}Testpublic void save() throws Exception {for (int i 0; i 10; i) {User user new User(jege i, 25 i);userMapper.insert(user);}}Testpublic void all() throws Exception {save();assertThat(userMapper.findAll()).hasSize(10);}Testpublic void findByName() throws Exception {save();assertThat(userMapper.findByNameLike(jege%)).hasSize(10);}// 每次执行Test之后清空数据Afterpublic void destroy() throws Exception {userMapper.deleteAll();}}扫一扫获取更多相关资讯哟
http://www.pierceye.com/news/118877/

相关文章:

  • 全景网站建设做米业的企业网站
  • 珠海哪个建设网站建设好ui网站界面设计
  • 中国有名的模版网站电商建设网站
  • 网站改域名合肥网站建设企业
  • 建网站需要软件c 怎么做能让窗体访问网站
  • 呼家楼网站建设黄骅市官方网站
  • 空包网站分站怎么做手表网站哪个最好知乎
  • 手机商城建站系统网站建设有关建筑网站建设方案
  • 做网站需要具备的基础条件wordpress 修改后台
  • 网站做点击收费标准重庆建设工业集团
  • wordpress个人网站备案管理广州网站搭建费用
  • 英文网站建设的原因泰安房产信息网网签查询
  • 怎么将网站做成html如何寻找一批做网站的公司
  • 苏州网站建设孙峰南宁站建站时间
  • 海淀手机网站设计公司苏州建设工程有限公司
  • 兰州网站设计制作王妃貌美还狠凶
  • 做新闻微网站有哪些淘宝优惠劵做网站模版
  • 网站维护的意义百度一下官网首页百度
  • 我是做网站怎么赚钱外贸网站google推广
  • 无锡网站seo报价软件开发模型是对软件开发过程的一种规范描述
  • 暴利产品竞价单页网站微信电商小程序开发公司
  • 网站中的搜索功能怎么做怎样在网站做友情链接
  • 新闻单位建设网站的意义怎么和其它网站做友情链接
  • 做哪类网站没有版权问题帮忙做公司网站
  • 商城式网站具备哪些功能吗郑州网站设
  • 潍坊市做网站沈阳专业网站制作团队
  • 婚恋网站女孩子都是做美容西安做网站南通公司
  • 网站制作培训中心想做网站建设
  • 免费模板素材网站ppth5开源网站模板
  • 建筑型专业网站有哪些网站想做个链接怎么做的