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

网站过期后瓯海网站建设

网站过期后,瓯海网站建设,商户网站唯一订单号,如何制作手机购物网站一、lombok插件 1. 功能#xff1a;对实体类自动#xff0c;动态生成get、set方法#xff0c;无参、有参构造..... 2. 步骤#xff1a; #xff08;1#xff09;idea安装插件(只做一次) #xff08;2#xff09;添加坐标 #xff08;3#xff09;编写注解 NoArgsCo…一、lombok插件 1. 功能对实体类自动动态生成get、set方法无参、有参构造..... 2. 步骤 1idea安装插件(只做一次) 2添加坐标 3编写注解 NoArgsConstructor :无参构造 AllArgsConstructor :全参构造 Data :get、set、toString方法 package com.apesource.pojo;import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor;import java.io.Serializable;NoArgsConstructor // 无参 AllArgsConstructor // 全参 Data // get、set、toString方法 public class Account implements Serializable {private int aid;private String aname;private int amoney;public Account(String aname,int amoney){this.anameaname;this.amoneyamoney;} }二、Serializable 一个对象序列化的接口一个类只有实现了Serializable接口它的对象才能被序列化。 序列化是将对象状态转换为可保持或传输的格式的过程。与序列化相对的是反序列化它将流转换为对象。这两个过程结合起来可以轻松地存储和传输数据。 三、dbUtil-阿帕奇提供操作数据库的插件 1. 依赖 2. 数据源和QuerryRunner注入applicationContext.html ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd!-- 加载资源文件 --context:property-placeholder locationclasspath:jdbc.properties/!-- 注入数据源 --bean iddataSource classcom.mchange.v2.c3p0.ComboPooledDataSourceproperty namedriverClass value${msg1}/property namejdbcUrl value${msg2}/property nameuser value${msg3}/property namepassword value${msg4}//bean!-- 注入QueryRunner --bean idqueryRunner classorg.apache.commons.dbutils.QueryRunnerconstructor-arg nameds refdataSource//bean!-- 注入dao --bean idmapperImp classcom.apesource.dao.AccountMapperImpproperty namequeryRunner refqueryRunner//bean!-- 注入service --bean idservice classcom.apesource.service.AccountServiceImpproperty namemapper refmapperImp//bean!-- 注入controller --bean idcontroller classcom.apesource.controller.AccountControllerImpproperty nameservice refservice//bean/beans 3. 核心类QueryRunner 4. QueryRunner提供的方法 1query()  查询 BeanHandler把结果集转为一个 Bean并返回。Bean的类型在创建BeanHandler 对象时以 Class 对象的方式传入 BeanHandler(ClassT type)。 BeanListHandler把结果集转为一个 Bean 的 List, 并返回。Bean的类型在创建 BeanListHanlder对象时以 Class对象的方式传入BeanListHandler(ClassT type)。 2update() 增删改 package com.apesource.dao;import com.apesource.pojo.Account; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.handlers.BeanHandler; import org.apache.commons.dbutils.handlers.BeanListHandler;import java.sql.SQLException; import java.util.List;public class AccountMapperImp implements IAccountMapper {// 操作数据库的核心类QueryRunner queryRunner;public void setQueryRunner(QueryRunner queryRunner) {this.queryRunner queryRunner;}Overridepublic void save(Account account) {try {queryRunner.update(insert into account(aname,amoney) values(?,?),account.getAname(),account.getAmoney());} catch (SQLException throwables) {throwables.printStackTrace();}}Overridepublic void deleteById(int id) {try {queryRunner.update(delete from account where aid ?,id);} catch (SQLException throwables) {throwables.printStackTrace();}}Overridepublic void updateById(Account account) {try {queryRunner.update(update account set aname?,amoney? where aid?,account.getAname(),account.getAmoney(),account.getAid());} catch (SQLException throwables) {throwables.printStackTrace();}}Overridepublic Account findByName(String name) {try {return queryRunner.query(select * from account where aname?,new BeanHandlerAccount(Account.class),name);} catch (SQLException throwables) {throwables.printStackTrace();}return null;}Overridepublic ListAccount findAll() {try {return queryRunner.query(select * from account,new BeanListHandlerAccount(Account.class));} catch (SQLException throwables) {throwables.printStackTrace();}return null;} }四、junit测试 1. 使用步骤 1坐标依赖 2注解 修饰方法 Test可以运行的方法 BeforeTest运行之前 AfterTest运行之后 基于xml实现 package com.apesource.test;import com.apesource.controller.IAccountController; import com.apesource.pojo.Account; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;import java.util.List;public class Test01 {ClassPathXmlApplicationContext applicationContext null;IAccountController controller null;Before // 测试运行前执行public void beforeMethod(){applicationContext new ClassPathXmlApplicationContext(applicationContext.xml);controller (IAccountController) applicationContext.getBean(controller);}After // 测试执行后执行public void afterMethod(){applicationContext.close(); // 关闭容器}Testpublic void show3(){controller.save(new Account(王五,7000));}Testpublic void show4(){ListAccount all controller.findAll();for (int i 0; i all.size(); i) {Account account all.get(i);System.out.println(account);}}}修饰类 RunWith(SpringJUnit4ClassRunner.class)让测试运行于Spring测试环境搭配ContextConfiguration 使用Spring整合JUnit4测试时使用注解引入多个配置文件。 基于annotation注解实现 package com.apesource.test;import com.apesource.controller.IAccountController; import com.apesource.pojo.Account; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import java.util.List;RunWith(SpringJUnit4ClassRunner.class) ContextConfiguration(locations classpath:applicationContext.xml) public class Test02 {AutowiredIAccountController controller;Testpublic void show1(){controller.save(new Account(小陈,6000));}Testpublic void show2(){ListAccount all controller.findAll();for (int i 0; i all.size(); i) {Account account all.get(i);System.out.println(account);}}Testpublic void show3(){Account account new Account();account.setAid(4);account.setAname(辰辰);account.setAmoney(8000);controller.updateById(account);}}
http://www.hkea.cn/news/14537476/

相关文章:

  • 保定网站建设苗木移动网站建设机构
  • 公司做网站的价格江阴开发区是什么意思
  • 企业网站群建设嘉兴专业自助建站免费咨询
  • 网站被挂马原因灵璧县住房和城乡建设局网站
  • 沈阳做企业网站哪家好网站的倒计时怎么做
  • 网站维护的具体问题vps 同时做ssh和做网站
  • 预约网站模板排名sem优化软件
  • 网站视频下载方法分销网站建设
  • 网站建设需要的项目如何卸载本地安装的wordpress
  • 徐州网站建设模板增加wordpress打开速度
  • 做外贸站推广wordpress通知
  • 可以充值的网站怎么建设温州做模具的网站
  • 做木质的网站wordpress绕绕
  • 北京朝阳网站有的网站在浏览器打不开怎么办
  • 之前做的网站推广怎么删除wordpress个人中心打不开
  • wordpress站点用户注册微信红包封面开放平台
  • 许昌市住房和城乡建设局网站微信手机网站支付怎么做
  • 做电商网站都需要学什么软件家教网站如何做
  • 电商网站首页布局受欢迎的企业网站建设
  • 工程施工行业在哪个网站容易找事做wordpress 什么框架
  • 柳市做网站团购小程序
  • 程序员前端和后端的区别南宁seo管理
  • 网站域名解绑卖营销软件的网站
  • 现在建网站软件wordpress wp-signup.php
  • 云龙湖旅游景区网站建设招标建站报价表
  • 阳春县建设局网站网站要咋做
  • 做一个网站平台的流程是什么做网站优化公司报价
  • 昆山企业网站制作公司wordpress设置成中文字体
  • 黄冈网站推广优化技巧福州网站设计哪家做的好
  • 手机小游戏网站一个人可以做网站吗