当前位置: 首页 > 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.zqtcl.cn/news/280657/

相关文章:

  • 莆田人做的网站一天赚2000加微信
  • 阿里云网站访问不了怎么办做网站二维码
  • 手机商城网站建设可采用的基本方式有
  • 网站备案管理做广告公司网站建设价格
  • 绵阳专业网站建设公司上海外贸公司排名榜
  • 如何做英文系统下载网站快速排名工具免费
  • 苏州建网站必去苏州聚尚网络网页视频提取在线工具
  • 网站建设服务市场分析百度集团
  • 网站怎么企业备案信息做网站业务员如何跟客户沟通
  • 如何网站推广知名的集团门户网站建设费用
  • 网站入口设计规范专门做喷涂设备的网站
  • 最简单网站开发软件有哪些企业管理培训课程培训机构
  • 桂城网站制作公司wordpress 导航网站
  • 一个公司做网站需要注意什么条件网站备案 登陆
  • 百度网站介绍显示图片装修公司一般多少钱一平方
  • 网站销售如何做业绩我找伟宏篷布我做的事ko家的网站
  • 建立网站有哪些步骤?jsp网站开发详细教程
  • 网站怎么做直播功能旅游做攻略用什么网站
  • 企业外贸营销型网站如何写好软文推广
  • 免费建站的网址个人网站建设程序设计
  • 淘宝网站建设违规吗上海大公司
  • 大淘客怎么自己做网站自己开网站能赚钱吗
  • 大型门户网站开发北京网站建设管庄
  • 大连建设工程网站网站建设组织管理怎么写
  • wordpress英文站注册域名需要注意什么
  • 营销型网站的建设重点是什么深圳logo设计公司排名
  • 做网站的用什么软件呢网站排名优化服务公司
  • 网站开发完整视频网站集约化建设较好的城市
  • 网站建设和平面设计应用网站如何做
  • 自己做网站需要多少费用asa8.4 做网站映射