springCould中的Hystrix【上】-从小白开始【7】

news2024/9/19 10:34:10

目录

1.简单介绍❤️❤️❤️

2.主要功能 ❤️❤️❤️

3.正确案例❤️❤️❤️

4.使用jmeter压测 ❤️❤️❤️

5.建模块 80❤️❤️❤️

6.如何解决上面问题 ❤️❤️❤️

7.对8001进行服务降级❤️❤️❤️

8.对80进行服务降级 ❤️❤️❤️

9.通用降级方法❤️❤️❤️

10.在Feign接口实现降级 ❤️❤️❤️


1.简单介绍❤️❤️❤️

Hystrix是一个用于处理分布式系统延迟和容错的开源库,在分布式系统里,许多依赖不可避免的会调用失败,比如超时、异常等,Hystrix能够保证在一个依赖出问题的情况下,不会导致整体服务失败,避免级联故障,以提高分布式系统的弹性。

2.主要功能 ❤️❤️❤️

  • 服务隔离:通过将不同的依赖服务调用分配给不同的线程池来隔离服务之间的调用,防止一个服务的故障导致整个系统的崩溃。
  • 服务降级当依赖服务出现延迟故障Hystrix可以提供一个备用的响应,避免用户等待超时或出现错误。
  • 服务熔断Hystrix可以根据依赖服务的错误率和延迟来决定是否打开断路器,当断路器打开时所有的请求将直接返回,避免对依赖服务的继续调用。
  • 服务限流Hystrix可以限制对依赖服务的并发调用数量,避免因过多的请求导致依赖服务的崩溃。
  • 实时监控和报警:Hystrix提供了实时的监控仪表盘,可以监控依赖服务的调用情况和错误率,并提供报警机制。

3.正确案例❤️❤️❤️

1.建模块

在父工程下创建,注意jdk和maven版本

2.写pom

1.springboot依赖

2.mysql依赖

3.mybatis依赖

4.eureka依赖

5.hystrix依赖

  <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.16</version>
        </dependency>
        <!--mysql-connector-java-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!--jdbc-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!--引入自己的api-->
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!--eureka的client-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <!--hystrix-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
    </dependencies>

3.写yml

1.服务端口

2.服务名称

3.数据库连接池

4.mybatis配置

5.入住到服务注册中心(eureka)

server:
  port: 8001

spring:
  application:
    name: cloud-provider-hystrix-payment
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/springcloud
    username: root
    password: 123456
mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.xz.springcloud.entity

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka,http://eureka7003.com:7003/eureka


4.主启动类

@SpringBootApplication
@EnableEurekaClient
public class PaymentHystrixMain8001 {
    public static void main(String[] args) {
        SpringApplication.run(PaymentHystrixMain8001.class);
    }
}

5.编写业务

创建两个方法:

1.正常方法没有延迟

2.错误方法有延时,Thread.sleep()模拟程序执行时间

@RestController
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;


    @GetMapping("/payment/hystrix/ok/{id}")
    public CommonResult paymentInfo_Ok(@PathVariable("id") Integer id) {
        Payment result = paymentService.getById_Ok(id);
        if (result != null) {
            return new CommonResult(200, "查寻成功,端口:" + serverPort+",线程池:"+Thread.currentThread().getName(), result);
        } else {
            return new CommonResult(404, "查询失败,端口:" + serverPort+",线程池:"+Thread.currentThread().getName());
        }
    }

    @GetMapping("/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id) throws InterruptedException {
        int timeOut = 3;
        Payment result = paymentService.getById_TimeOut(id);
        if (result != null) {
            TimeUnit.SECONDS.sleep(3);
            return new CommonResult(200, "查寻成功,端口:"+ serverPort+",线程池:"+Thread.currentThread().getName()  + ",超时时间:" + timeOut, result);
        } else {
            return new CommonResult(404, "查询失败,端口:"+ serverPort+",线程池:"+Thread.currentThread().getName()  + ",超时时间:" + timeOut);
        }
    }
}

 6.测试:

1.paymentInfo_ok,没有延迟,直接查询到

2.paymentInfo_TimeOut,有延迟,三秒后查询到

4.使用jmeter压测 ❤️❤️❤️

  • 1.创建线程组-取样器-HTTP请求

  • 2.设置压测数据 

 

  • 3.启动压测,同时刷新正常的请求Ok 

 

发现之前没有设置延迟的接口,访问时也变得十分缓慢。。。 

原因:tomcat的默认的工作线程数被打满了,没有多余的线程来分解压力和处理。

这就导致,我们访问同一服务下的其他接口地址也变得缓慢

5.建模块 80❤️❤️❤️

1.建模块

在父工程下创建,注意jdk版本和maven版本

2.写pom

1.springboot依赖

2.通用依赖

3.eureka依赖

4.OpenFeign依赖

5.Hystri依赖

 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!--eureka的Client端-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <!--openFeign-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
    </dependencies>

3.加yml

1.服务端口

2.入住eureka配置信息

server:
  port: 80
eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka,http://eureka7003.com:7003/eureka

4.主启动

使用OpenFeign,添加@EnableFeignClients

@SpringBootApplication
@EnableFeignClients
public class OrderHystrixMain80 {
    public static void main(String[] args) {
        SpringApplication.run(OrderHystrixMain80.class);
    }

}

5.@FeignClient接口

1.使用@Component,交给spring管理

2.添加@FeignClient(value="要访问服务的名称")

3.要访问服务的哪个接口

@Component
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT")
public interface PaymentHystrixService {

    @GetMapping("/payment/hystrix/ok/{id}")
    public CommonResult paymentInfo_Ok(@PathVariable("id") Integer id);

    @GetMapping("/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id);

}

6.编写业务

@RestController
public class OrderHystrixController {

    @Autowired
    private PaymentHystrixService paymentHystrixService;


    @GetMapping("/consumer/payment/hystrix/ok/{id}")
    public CommonResult paymentInfo_Ok(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentInfo_Ok(id);
    }

    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentInfo_TimeOut(id);
    }
}

7.压测

当正常访问ok方法时,浏览器返回基本是刹那间

当我们压测timeout方法时,再去使用80访问ok方法,结果发现直接返回错误页面。

8001同一层次的其它接口服务被困死,因为tomcat线程池里面的工作线程已经被挤占完毕

6.如何解决上面问题 ❤️❤️❤️

  • 对方服务(8001)超时了,调用者(80)不能一直卡死等待,必须有服务降级
  • 对方服务(8001)down机了,调用者(80)不能一直卡死等待,必须有服务降级
  • 对方服务(8001)OK,调用者(80)自己出故障或有自我要求(自己的等待时间小于服务提供者)自己处理降级

7.对8001进行服务降级❤️❤️❤️

1.添加@HystrixCommand注解

属性:

1.fallbackMethod:当超时后,要返回的兜底方法

2.@HystrixProperty:设置多少秒没有响应,返回兜底方法

@HystrixCommand(fallbackMethod = "paymentInfo_TimeOutHandler",commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "3000")
    })
    @GetMapping("/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id) throws InterruptedException {

        int timeOut = 5;
        Payment result = paymentService.getById_TimeOut(id);
        if (result != null) {
            TimeUnit.SECONDS.sleep(3);
            return new CommonResult(200, "查寻成功,端口:"+ serverPort+",线程池:"+Thread.currentThread().getName()  + ",超时时间:" + timeOut, result);
        } else {
            return new CommonResult(404, "查询失败,端口:"+ serverPort+",线程池:"+Thread.currentThread().getName()  + ",超时时间:" + timeOut);
        }
    }

2.创建兜底方法

  public CommonResult paymentInfo_TimeOutHandler(@PathVariable("id") Integer id){
        Payment result = paymentService.getById_TimeOut(id);
        if (result != null) {
            return new CommonResult(200, "系统繁忙!稍后重试~");
        } else {
            return new CommonResult(404, "备用~查询失败,端口:" + serverPort+",线程池:"+Thread.currentThread().getName());
        }
    }

3.主启动类添加@EnableCircuitBreaker

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
public class PaymentHystrixMain8001 {
    public static void main(String[] args) {
        SpringApplication.run(PaymentHystrixMain8001.class);
    }
}

4.测试

1.当调用的接口超时,返回兜底数据

2.放调用的接口中存在运行时错误,也会返回兜底数据

8.对80进行服务降级 ❤️❤️❤️

1.改yml

启用Hystrix作为Feign的断路器

feign:
  hystrix:
    enabled: true

2.添加@HystrixCommand注解 

   @HystrixCommand(fallbackMethod = "paymentTimeOutFallbackMethod",commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "1500")
    })
    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentInfo_TimeOut(id);
    }

3.创建兜底方法

注意方法的返回值类型必须原方法一致!

 public CommonResult  paymentTimeOutFallbackMethod(@PathVariable("id") Integer id){
        return new CommonResult(200,"我是消费80,系统繁忙,稍后重试~");
    }

4.主启动添加@Enablehystrix

@SpringBootApplication
@EnableFeignClients
@EnableHystrix
public class OrderHystrixMain80 {
    public static void main(String[] args) {
        SpringApplication.run(OrderHystrixMain80.class);
    }

}

5.测试

1.当使用feign调用的方法超时,返回兜底数据

2.当feign调用的方法存在运行时错误,返回兜底数据

9.通用降级方法❤️❤️❤️

1.问题

配置降级服务时,每个方法都要有降级的方法。显然代码膨胀,不好管理

 @HystrixCommand(fallbackMethod = "paymentTimeOutFallbackMethod",commandProperties = {
           @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "1500")
    })

2.解决(@DefaultProperties

使用@DefaultProperties(defaultFallback="全局降级的方法")

需要服务降级的方法,仍需要添加@HystrixCommand

@RestController
@DefaultProperties(defaultFallback = "payment_Global_FallbackMethod")
public class OrderHystrixController {

    @HystrixCommand
    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id) {
        return paymentHystrixService.paymentInfo_TimeOut(id);
    }
   //全局fallback
    public CommonResult payment_Global_FallbackMethod(){
        return new CommonResult(200,"全局配置处理,系统繁忙,稍后重试");
    }

}

3.测试

10.在Feign接口实现降级❤️❤️❤️ 

1.改yml

启用Hystrix作为Feign的断路器

feign:
  hystrix:
    enabled: true

2.创建实现Feign接口类

1.创建一个类,实现有@FeignClient标记的接口

2.添加@Component注解,交给spring管理

@Component
public class PaymentFallbackService implements PaymentHystrixService{
    @Override
    public CommonResult paymentInfo_Ok(Integer id) {
        return new CommonResult(200,"payment_ok,系统繁忙,稍后重试~");
    }

    @Override
    public CommonResult paymentInfo_TimeOut(Integer id) {
        return new CommonResult(200,"payment_TimeOut,系统繁忙,稍后重试~");
    }
}

3.在@FeignClien中添加属性:fallback

fallback:返回的兜底类(实现当前接口的类)

@Component
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT",fallback = PaymentFallbackService.class)
public interface PaymentHystrixService {

    @GetMapping("/payment/hystrix/ok/{id}")
    public CommonResult paymentInfo_Ok(@PathVariable("id") Integer id);

    @GetMapping("/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_TimeOut(@PathVariable("id") Integer id);

}

4.测试

当服务8001宕机之后,访问正常接口ok时,返回兜底数据

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1354788.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

win10提示“KBDSF.DLL文件缺失”,游戏或软件无法启动运行,快速修复方法

很多用户在日常使用电脑的时候&#xff0c;或多或少都遇到过&#xff0c;在启动游戏或软件的时候&#xff0c;Windows桌面会弹出错误提示框“KBDSF.DLL文件缺失&#xff0c;造成软件无法启动或运行&#xff0c;请尝试重新安装解决”。 首先&#xff0c;先来了解DLL文件是什么&a…

【计算机毕业设计】SSM场地预订管理系统

项目介绍 本项目分为前后台&#xff0c;前台为普通用户登录&#xff0c;后台为管理员登录&#xff1b; 用户角色包含以下功能&#xff1a; 按分类查看场地,用户登录,查看网站公告,按分类查看器材,查看商品详情,加入购物车,提交订单,查看订单,修改个人信息等功能。 管理员角…

急急急!直接从压缩包打开文件,保存后再打开却找不到了怎么办???

这是我今天发生的蠢事&#xff0c;好险&#xff0c;改了一个上午的word文档&#xff0c;因为word突然未响应&#xff0c;强制关闭后再打开word文档找不到了才想起来自己没有解压缩就。。。。 &#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#…

绿色环保之选:探索智慧公厕公司厂家的可持续发展策略

随着城市化的不断推进&#xff0c;如何在城市中创造更为宜居的环境成为了当今社会亟待解决的问题。在这个背景下&#xff0c;智慧公厕公司厂家应运而生&#xff0c;不仅通过引入创新技术提升了公共卫生水平&#xff0c;更以其独特的可持续发展策略成为了绿色环保之选。 符合智慧…

未来十年不变的AI是什么?吴恩达等专家关于2024年AI发展趋势的预测

随着2024年的到来&#xff0c;人工智能领域正迎来前所未有的变革和发展。从深度学习到自然语言处理&#xff0c;AI技术的每一个分支都在经历着快速的进步。在这个关键的时刻&#xff0c;业界专家们提出了对未来趋势的深刻洞察&#xff0c;预测了将形成AI发展主流的关键方向。智…

DolphinScheduler实际应用

前言 最近公司新启动了一个项目&#xff0c;然后领导想用一下新技术&#xff0c;并且为公司提供多个大数据调度解决方案&#xff0c;我呢就根据领导要求调研了下当前的开源调度工具&#xff0c;最终决定采用DolphinScheduler&#xff0c; 因此研究了一下DolphinScheduler &…

JSON网络令牌JWT

1.什么是身份验证 日常生活中的身份验证的场景: 比如进入公司的大楼时&#xff0c;需要携带工牌&#xff1b;打卡上班时&#xff0c;需要指纹识别&#xff1b;打开工作电脑时&#xff0c;需要输入密码。 2. 什么是 JSON 网络令牌&#xff1f; JSON Web Token (JWT) 是一个开…

大数据技术在民生资金专项审计中的应用

一、应用背景 目前&#xff0c;针对审计行业&#xff0c;关于大数据技术的相关研究与应用一般包括大数据智能采集数据技术、大数据智能分析技术、大数据可视化分析技术以及大数据多数据源综合分析技术。其中&#xff0c;大数据智能采集数据技术是通过网络爬虫或者WebService接…

【数据结构和算法】小行星碰撞

其他系列文章导航 Java基础合集数据结构与算法合集 设计模式合集 多线程合集 分布式合集 ES合集 文章目录 其他系列文章导航 文章目录 前言 一、题目描述 二、题解 2.1 什么情况会用到栈 2.2 方法一&#xff1a;模拟 栈 三、代码 3.1 方法一&#xff1a;模拟 栈 四…

单轴PSO视觉飞拍与精准输出:EtherCAT超高速实时运动控制卡XPCIE1032H上位机C#开发(七)

XPCIE1032H功能简介 XPCIE1032H是一款基于PCI Express的EtherCAT总线运动控制卡&#xff0c;可选6-64轴运动控制&#xff0c;支持多路高速数字输入输出&#xff0c;可轻松实现多轴同步控制和高速数据传输。 XPCIE1032H集成了强大的运动控制功能&#xff0c;结合MotionRT7运动…

CRYPTO现代密码学学习

CRYPTO现代密码学学习 RC4 加密算法RSA加密解密DES加密解密详解密钥的生成密文的生成 RC4 加密算法 简单介绍&#xff1a;RC4加密算法是一种对称加密算法&#xff0c;加密和解密使用同一个函数 初始化分为以下几个步骤 初始化存储0-255字节的Sbox(其实就是一个数组)填充key到…

金融中IC和IR的定义

当谈到金融领域时&#xff0c;IC&#xff08;Information Coefficient&#xff09;和IR&#xff08;Information Ratio&#xff09;通常是用来评估投资组合管理绩效的指标。它们都涉及到投资者对信息的利用和管理的效果。 信息系数&#xff08;IC - Information Coefficient&a…

使用Go语言采集1688网站数据对比商品价格

目录 引言 一、数据采集原理 二、数据采集流程 三、数据采集代码实现 四、数据分析与比较 五、注意事项 六、结论 引言 随着电子商务的快速发展&#xff0c;越来越多的消费者开始通过在线平台购买商品。在众多电商平台中&#xff0c;1688作为中国最大的批发交易平台&am…

三、C语言中的分支与循环—if语句 (1)

在这一章节中我们的学习内容如下&#xff0c;咱们一步步来。 分支结构 1. if语句 2. 关系操作符 3. 条件操作符 4. 逻辑操作符&#xff1a;&& , || , &#xff01; 5. switch语句 循环结构 6. while循环 7. for循环 8. do-while循环 9. break和conti…

kubeadm创建k8s集群

kubeadm来快速的搭建一个k8s集群&#xff1a; 二进制搭建适合大集群&#xff0c;50台以上。 kubeadm更适合中下企业的业务集群。 部署框架 master192.168.10.10dockerkubelet kubeadm kubectl flannelnode1192.168.10.20dockerkubelet kubeadm kubectl flannelnode2192.168.1…

vue3 + TS + vite 搭建中后台管理系统(完整项目)

vue3 TS vite 搭建中后台管理系统&#xff08;完整项目&#xff09; 前言1、搭建步骤及方法2、集成多种插件功能&#xff0c;实现中后台按需使用3、新手学TS如何快速进入状态、定义TS类型4、layout搭建四款常见风格6、大屏搭建效果5、vue3Ts运营管理系统总结&#xff1a; 前言…

2020年认证杯SPSSPRO杯数学建模C题(第一阶段)抗击疫情,我们能做什么全过程文档及程序

2020年认证杯SPSSPRO杯数学建模 C题 抗击疫情&#xff0c;我们能做什么 原题再现&#xff1a; 2020 年 3 月 12 日&#xff0c;世界卫生组织&#xff08;WHO&#xff09;宣布&#xff0c;席卷全球的冠状病毒引发的病毒性肺炎&#xff08;COVID-19&#xff09;是一种大流行病。…

Mybatis Plus 基础功能 BaseMapper和基础配置以及注解

文章目录 Mybatis Plus导入依赖定义Mapper约定常见配置 Mybatis Plus 导入依赖 官网看一下也行plus官网 spring boot3 版本<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId><vers…

易点易动固定资产管理系统集成企业微信,帮助企业全生命周期管理固定资产

在现代企业中&#xff0c;固定资产管理是一项至关重要的任务。固定资产的高效管理可以提高企业的运营效率、降低成本&#xff0c;并确保资产的安全和稳定。然而&#xff0c;传统的固定资产管理方法往往复杂繁琐&#xff0c;容易出现信息不准确、流程不畅和数据不一致的问题。为…

Pikachu--字符型注入(get)

Pikachu--字符型注入&#xff08;get&#xff09; 提交方式是get提交&#xff0c;直接在浏览器地址栏里输入注入语句得出结果 判断注入类型 我们要输入数据库里面有的名字 比如vince 输入1 and 12 错误结果 输入 1 and 11 正确结果 判断为字符型注入 判断字段数 输…