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

网站运营策划提案比百度好用的搜索引擎

网站运营策划提案,比百度好用的搜索引擎,兰州网新公司,域名注册后怎么做网站一、lombok插件 1. 功能:对实体类自动,动态生成get、set方法,无参、有参构造..... 2. 步骤: (1)idea安装插件(只做一次) (2)添加坐标 (3)编写注解 NoArgsCo…

一、lombok插件

1. 功能:对实体类自动,动态生成get、set方法,无参、有参构造.....

2. 步骤

        (1)idea安装插件(只做一次)

        (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.aname=aname;this.amoney=amoney;}
}

二、Serializable

        一个对象序列化的接口,一个类只有实现了Serializable接口,它的对象才能被序列化。

        序列化是将对象状态转换为可保持或传输的格式的过程。与序列化相对的是反序列化,它将流转换为对象。这两个过程结合起来,可以轻松地存储和传输数据。

三、dbUtil-阿帕奇提供操作数据库的插件

1. 依赖:

        

2. 数据源QuerryRunner注入(applicationContext.html)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://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 location="classpath:jdbc.properties"/><!-- 注入数据源 --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="${msg1}"/><property name="jdbcUrl" value="${msg2}"/><property name="user" value="${msg3}"/><property name="password" value="${msg4}"/></bean><!-- 注入QueryRunner --><bean id="queryRunner" class="org.apache.commons.dbutils.QueryRunner"><constructor-arg name="ds" ref="dataSource"/></bean><!-- 注入dao --><bean id="mapperImp" class="com.apesource.dao.AccountMapperImp"><property name="queryRunner" ref="queryRunner"/></bean><!-- 注入service --><bean id="service" class="com.apesource.service.AccountServiceImp"><property name="mapper" ref="mapperImp"/></bean><!-- 注入controller --><bean id="controller" class="com.apesource.controller.AccountControllerImp"><property name="service" ref="service"/></bean></beans>

3. 核心类QueryRunner

4. QueryRunner提供的方法

        (1)query()  查询

                BeanHandler:把结果集转为一个 Bean,并返回。Bean的类型在创建BeanHandler 对象时以 Class 对象的方式传入 BeanHandler(Class<T> type)。

           BeanListHandler:把结果集转为一个 Bean 的 List, 并返回。Bean的类型在创建 BeanListHanlder对象时以 Class对象的方式传入BeanListHandler(Class<T> type)。

        (2)update() 增删改

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 BeanHandler<Account>(Account.class),name);} catch (SQLException throwables) {throwables.printStackTrace();}return null;}@Overridepublic List<Account> findAll() {try {return queryRunner.query("select * from account",new BeanListHandler<Account>(Account.class));} catch (SQLException throwables) {throwables.printStackTrace();}return null;}
}

四、junit测试

1. 使用步骤

        (1)坐标(依赖)

        

        (2)注解

                修饰方法

                        @Test======>可以运行的方法

                        @Before====>@Test运行之前

                        @After=====>@Test运行之后

                基于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(){List<Account> 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(){List<Account> 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.yidumall.com/news/96686.html

相关文章:

  • 怎么做网站底部备案号sem数据分析
  • 网站制作方案设计线下推广方法及策略
  • 网站代理游戏杭州今天查出多少阳性
  • 215做网站谷歌sem
  • 展览展示设计必看网站网站分析报告
  • 厦门网站推广费用中国唯一没有疫情的地方
  • 做个小网站大概多少钱sem培训机构
  • 哪里有做网站技术治疗腰椎间盘突出的特效药
  • 手机微信可以做网站吗产品推广网站哪个好
  • 静态网站怎么样百度一下官网
  • 公司网站空间域名建设线上引流线下推广方案
  • 那个网站做玉石最专业企业网站建设的一般要素
  • 网站策划编辑招聘网盘资源大全
  • 网站优化外包公司系统优化软件排行榜
  • 网站建设设计师招募人工智能培训机构
  • 昆明做网站优化价格百度收录入口提交查询
  • 17网站一起做网店类似的app网络推广方案
  • wordpress隐藏自定义网站优化排名软件
  • 网址域名ip解析上海百度seo牛巨微
  • vip解析网站如何做星乐seo网站关键词排名优化
  • 番禺做网站开发个人主页网页设计模板
  • 网站开发建设的步骤流感用什么药最好
  • wordpress红色主题seo自动工具
  • 河南做酒店网络系统网站如何优化网络
  • 企业网站会涉及到的版权问题地域名网址查询
  • 网站seo优化心得代做百度首页排名
  • 内网是怎么做网站的湘潭网页设计
  • 房屋中介做网站的书籍关键词优化排名用哪个软件比较好
  • 做网站需要什么费用模板网站哪个好
  • 外贸网站建站案例it人必看的网站