springcloud整合Hystrix

2023-11-18

作用

1、服务降级
触发情况:程序运行异常、超时、服务熔断触发服务降级、线程池/信号量打满也会触发服务降级
2、服务熔断
直接拒绝访问,即使有正确的访问也会短路
3、服务限流
排队有序进行

构建服务

1、建module
provider-hystrix-payment8001
2、改pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>cloud2020</artifactId>
        <groupId>com.atguigu.springcloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cloud-provider-hystrix-payment8001</artifactId>


    <dependencies>
        <!--新增hystrix-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>


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

        <dependency>
            <groupId>com.atguigu.springcloud</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>${project.version}</version>
        </dependency>


        <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.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>
    </dependencies>

</project>

3、 配yml

server:
  port: 8001

spring:
  application:
    name: cloud-provider-hystrix-payment

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

4、主启动

@SpringBootApplication
@EnableEurekaClient
//注解开启断路器功能
@EnableCircuitBreaker
public class CloudProviderHystrixPayment8001Application {
    public static void main(String[] args) {
        SpringApplication.run(CloudProviderHystrixPayment8001Application.class, args);
        System.out.println("启动成功");
    }
}

5、service

@Service
public class PaymentService {
    /**
     * 正常访问,肯定OK
     *
     * @param id
     * @return
     */
    public String paymentInfoOK(Integer id) {
        return "线程池:  " + Thread.currentThread().getName() + "  paymentInfoOK,id:  " + id + "\t"
                + "O(∩_∩)O哈哈~";
    }


    /**
     * 超时访问,设置自身调用超时的峰值,峰值内正常运行,超过了峰值需要服务降级 自动调用fallbackMethod 指定的方法
     * 超时异常或者运行异常 都会进行服务降级
     *
     * @param id
     * @return
     */
    @HystrixCommand(fallbackMethod = "paymentInfoTimeOutHandler", commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")
    })
    public String paymentInfoTimeOut(Integer id) {
//        int age = 10/0;
        int second = 3;
        long start = System.currentTimeMillis();
        try {
            TimeUnit.SECONDS.sleep(second);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
        return "线程池:  " + Thread.currentThread().getName() + " paymentInfoTimeOut,id:  " + id + "\t"
                + "O(∩_∩)O哈哈~" + "  耗时(秒): " + second;
    }
}

6、controller

@RestController
@RequestMapping("payment")
@Slf4j
public class PaymentController {
    /**
     * 服务对象
     */
    @Resource
    private PaymentService paymentService;

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


    /**
     * 正常访问
     *
     * @param id
     * @return
     */
    @GetMapping("/hystrix/ok/{id}")
    public String paymentInfoOK(@PathVariable("id") Integer id) {
        String result = paymentService.paymentInfoOK(id);
        log.info("result: " + result);
        return result;
    }


    /**
     * 超时或者异常
     *
     * @param id
     * @return
     */
    @GetMapping("/hystrix/timeout/{id}")
    public String paymentInfoTimeOut(@PathVariable("id") Integer id) {
        String result = paymentService.paymentInfoTimeOut(id);
        log.info("result: " + result);
        return result;
    }
}

7、测试
正常访问:http://localhost:8001/payment/hystrix/ok/31
5s返回:http://localhost:8001/payment/hystrix/timeout/31

高并发测试

1、jmeter压力测试
开启Jmeter,来20000个并发压死8001,20000个请求都去访问paymentInfo_TimeOut服务
2、访问上面的测试地址发现两个地址都加载不出或者卡死:tomcat默认的工作线程满了,没有多余的线程来来处理访问
3、加入order服务来调用payment生产者接口
4、建module
cloud-consumer-hystrix-order80
5、改pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>cloud2020</artifactId>
        <groupId>com.atguigu.springcloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cloud-consumer-feign-hystrix-order80</artifactId>

    <dependencies>
        <!--新增hystrix-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atguigu.springcloud</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>${project.version}</version>
        </dependency>
        <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.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>
    </dependencies>


</project>

6、配yml

server:
  port: 80

eureka:
  client:
    register-with-eureka: false
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka/

7、主启动

@SpringBootApplication
@EnableFeignClients // 启动 feign
@EnableHystrix // 启动 hystrix
public class CloudConsumerFeignHystrixOrder80Application {

    public static void main(String[] args) {
        SpringApplication.run(CloudConsumerFeignHystrixOrder80Application.class, args);
        System.out.println("启动成功");

    }

}

8、service

@Component
// FeignFallback 客户端的服务降级 针对 CLOUD-PROVIDER-HYSTRIX-PAYMENT 该服务 提供了一个 对应的服务降级类
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT", fallback = PaymentFallbackServiceImpl.class)
//@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT")
public interface PaymentHystrixService {
    @GetMapping("/payment/hystrix/ok/{id}")
    String paymentInfoOK(@PathVariable("id") Integer id);

    @GetMapping("/payment/hystrix/timeout/{id}")
    String paymentInfoTimeOut(@PathVariable("id") Integer id);
}

9、controller

@RestController
@RequestMapping("consumer")
@Slf4j
public class OrderHystrixController {
    @Resource
    private PaymentHystrixService paymentHystrixService;

    @GetMapping("/payment/hystrix/ok/{id}")
    public String paymentInfoOK(@PathVariable("id") Integer id) {
        String result = paymentHystrixService.paymentInfoOK(id);
        return result;
    }


    @GetMapping("/payment/hystrix/timeout/{id}")
//    @HystrixCommand(fallbackMethod = "paymentTimeOutFallbackMethod", commandProperties = {
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")
//    })
    @HystrixCommand
    public String paymentInfoTimeOut(@PathVariable("id") Integer id) {
        int age = 10 / 0;
        String result = paymentHystrixService.paymentInfoTimeOut(id);
        return result;
    }
}

10、测试
http://localhost/consumer/payment/hystrix/ok/31
11、高并发测试
2w个线程压8001,发现order服务访问一直转圈,或者报超时错误
结论:我们需要有降级、熔断、限流等策略解决问题

8001服务端自身调用fallback

1、主启动修改
@EnableCircuitBreaker
2、接口注解添加

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

3、添加fallback方法

    /**
     * paymentInfoTimeOut 方法失败后 自动调用此方法 实现服务降级 告知调用者 paymentInfoTimeOut 目前无法正常调用
     *
     * @param id
     * @return
     */
    public String paymentInfoTimeOutHandler(Integer id) {
        return "线程池:  " + Thread.currentThread().getName() + "  paymentInfoTimeOutHandler8001系统繁忙或者运行报错,请稍后再试,id:  " + id + "\t"
                + "o(╥﹏╥)o";
    }

4、测试

order80端fallback

1、修改yml

feign:
  hystrix:
    enabled: true #如果处理自身的容错就开启。开启方式与生产端不一样。

2、修改主启动
@EnableHystrix
3、业务类

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

4、测试

问题

1、每个业务接口都需要有一个兜底的fallback方法,代码膨胀
2、统一的fallback方法如何和自定义的fallback方法分开

解决问题

1、 controller添加统一的fallback

@DefaultProperties(defaultFallback = "payment_Global_FallbackMethod")// hystrix 全局fallback方法

2、为接口方法进行统一的异常处理
PaymentFallbackService类实现PaymentFeignClientService接口

@Component
public class PaymentFallbackServiceImpl implements PaymentHystrixService {

    @Override
    public String paymentInfoOK(Integer id) {
        return "-----PaymentFallbackService fall back-paymentInfo_OK ,o(╥﹏╥)o";
    }

    @Override
    public String paymentInfoTimeOut(Integer id) {
        return "-----PaymentFallbackService fall back-paymentInfo_TimeOut ,o(╥﹏╥)o";
    }

}

3、修改yml

feign:
  hystrix:
    enabled: true #如果处理自身的容错就开启。开启方式与生产端不一样。

4、修改PaymentHystrixService接口,添加统一的fallback

@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT", fallback = PaymentFallbackServiceImpl.class)

5、 测试
1、正常访问:http://localhost/consumer/payment/hystrix/ok/31
2、异常访问:关闭provider,访问降级

服务熔断

是什么

熔断机制是一种应对雪崩效应的微服务链路保护机制

实操

1、修改provider-hystrix-payment8001

   /**
     * 服务熔断 超时、异常、都会触发熔断
     * 1、默认是最近10秒内收到不小于10个请求,<br/>
     * 2、并且有60%是失败的<br/>
     * 3、就开启断路器<br/>
     * 4、开启后所有请求不再转发,降级逻辑自动切换为主逻辑,减小调用方的响应时间<br/>
     * 5、经过一段时间(时间窗口期,默认是5秒),断路器变为半开状态,会让其中一个请求进行转发。<br/>
     * &nbsp;&nbsp;5.1、如果成功,断路器会关闭,<br/>
     * &nbsp;&nbsp;5.2、若失败,继续开启。重复4和5<br/>
     *
     * @param id
     * @return
     */
    @HystrixCommand(fallbackMethod = "paymentCircuitBreakerFallback", commandProperties = {
            @HystrixProperty(name = "circuitBreaker.enabled", value = "true"),/* 是否开启断路器*/
            @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "10"),// 请求次数
            @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000"), // 时间窗口期
            @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "60"),// 失败率达到多少后跳闸
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")// 超时处理
    })
    public String paymentCircuitBreaker(Integer id) {
        if (id < 0) {
            throw new RuntimeException("******id 不能负数");
        }
        //测试异常
//        int age = 10 / 0;
//        int second = 3;
//        try {
//            TimeUnit.SECONDS.sleep(second);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }


        String serialNumber = IdUtil.simpleUUID();
        return Thread.currentThread().getName() + "\t" + "调用成功,流水号: " + serialNumber;
    }


    /**
     * paymentCircuitBreaker 方法的 fallback,<br/>
     * 当断路器开启时,主逻辑熔断降级,该 fallback 方法就会替换原 paymentCircuitBreaker 方法,处理请求
     *
     * @param id
     * @return
     */
    public String paymentCircuitBreakerFallback(Integer id) {
        return Thread.currentThread().getName() + "\t" + "id 不能负数或超时或自身错误,请稍后再试,/(ㄒoㄒ)/~~   id: " + id;
    }

2、修改paymentController

/**
     * 服务熔断
     *
     * @param id
     * @return
     */
    @GetMapping("/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
        String result = paymentService.paymentCircuitBreaker(id);
        log.info("****result: " + result);
        return result;
    }

3、测试
正确:http://localhost:8001/payment/circuit/31
错误:http://localhost:8001/payment/circuit/-31
重点测试:多次错误,然后慢慢正确,发现刚开始不满足条件,就算是正确的访问地址也不能进行访问,需要慢慢的恢复链路

服务限流

后面总结sentinel再讲

HystrixDashboard

记录通过Hystrix链路访问的成功和失败数量的统计,图表等
1、建module
consumer-hystrix-dashboard9001
2、改pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>cloud2020</artifactId>
        <groupId>com.atguigu.springcloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cloud-consumer-hystrix-dashboard9001</artifactId>


    <dependencies>
        <!--新增hystrix dashboard-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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>
    </dependencies>

</project>

3、配置yml

server:
  port: 9001

4、主启动配置注解@EnableHystrixDashboard

@SpringBootApplication
@EnableHystrixDashboard
public class CloudConsumerHystrixDashboard9001Application {

    public static void main(String[] args) {
        SpringApplication.run(CloudConsumerHystrixDashboard9001Application.class, args);
        System.out.println("启动成功");

    }

}

5、所有Provider微服务提供类(8001/8002/8003)都需要监控依赖配置

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

6、启动服务访问
http://localhost:9001/hystrix

演示

1、修改provider-hystrix-payment8001
注意:新版本Hystrix需要在主启动类MainAppHystrix8001中指定监控路径

    /**
     * 注意:新版本Hystrix需要在主启动类中指定监控路径
     * 此配置是为了服务监控而配置,与服务容错本身无关,spring cloud升级后的坑
     * ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
     * 只要在自己的项目里配置上下面的servlet就可以了
     *
     * @return ServletRegistrationBean
     */
    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);

        // 一启动就加载
        registrationBean.setLoadOnStartup(1);
        // 添加url
        registrationBean.addUrlMappings("/hystrix.stream");
        // 设置名称
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }

2、9001监控8001
在这里插入图片描述
监控地址:http://localhost:8001/hystrix.stream
3、测试地址
正确:http://localhost:8001/payment/circuit/31
错误:http://localhost:8001/payment/circuit/-31
查看dashboard

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

springcloud整合Hystrix 的相关文章

  • C# 与 JAVA 接口实例

    我不知道该如何回答我的问题 它是关于Android可以实例化接口的 我正在尝试用 C 来做 现在我非常确定 Java 和 C 的规则是不能创建抽象和接口的实例 但我很想知道Android是如何做到这一点的 在 Android 中你可以这样做
  • 使用 BlobOutputStream 在 Azure 中上传 blob

    我正在尝试直接从流上传 blob 因为我不知道我决定尝试的流的长度这个答案 https stackoverflow com a 24621538 3695939 这不起作用 即使它从流中读取并且不会抛出任何异常 内容也不会上传到我的容器 我
  • 相当于 java PBKDF2WithHmacSHA1 的 Python

    我的任务是构建一个 API 的使用者 该 API 需要带有 UNIX 时间种子值的加密令牌 我看到的示例是使用我不熟悉的 Java 实现的 在阅读文档和其他堆栈文章后一直无法找到解决方案 使用javax crypto SecretKey j
  • Google App Engine 数据存储写入:如何远程启用/禁用只读模式?

    在阅读备份时GAE 的数据存储 https developers google com appengine docs adminconsole datastoreadmin where 我们强烈建议您在备份或恢复期间将应用程序设置为只读模式
  • 将键与多个值对象关联的有效集合[重复]

    这个问题在这里已经有答案了 有任何有效的集合可以将键与多个值关联起来 例如 new HashMap
  • 从 Eclipse 导出后,WAR 文件中缺少一些必要的库 - 为什么?

    我接手了一个大学的项目 其中包含一些 Web 服务 通过将项目导出为 WAR 文件 一些库包含在文件中 例如 Axis2 而另一些则不包含 hibernate JDBC 驱动程序 另外 添加到类路径中的 jar 尚未导出 所有库都位于硬盘驱
  • Java:等于和==

    让我们看看我们有 2 个对用户定义类实例的引用 即 Java 中的 a 和 b 会不会有一种情况 a b 但 a equals b 返回 false 当然 实施 equals 完全取决于班级 所以我可以写 class Foo public
  • 我从 String placeName = placeText.getText().toString(); 收到空指针异常

    您好 想从编辑文本中获取地名并在地图上标记 这是我的代码 其中出现空指针异常 请帮助我应该做什么以及哪里出错了 因为我从对话框中的编辑文本字段获取地名 View layout View inflate this R layout alert
  • Map:为 Integer 和 Double 类型定义方法,但不为 String 类型定义方法

    我正在尝试定义一个方法putIfGreaterThan 为了我的新Map class 给定一个键 仅当新值大于旧值时 它才会用新值替换旧值 我知道我可以通过组合来实现这一点 通过有一个private final Map
  • 对象映射器 - YAMLFactory - 由于缺少 _createContentReference 方法而出现异常

    我正在使用最新的 2 13 0 版本的 jackson 当我尝试解析 YAML 文件时 出现此异常 java lang NoSuchMethodError com fasterxml jackson core io ContentRefer
  • SwingUtilities.invokeLater

    我的问题与SwingUtilities invokeLater 我应该什么时候使用它 每次需要更新 GUI 组件时都必须使用吗 它到底有什么作用 是否有替代方案 因为它听起来不直观并且添加了看似不必要的代码 Do I have to use
  • 在实现接口的类上强制使用单例模式

    我最好用一个例子来解释这个问题 我有一个接口模型可用于访问数据 模型可以有不同的实现 可以以各种格式表示数据 例如 XMl txt 格式等 Model不关心格式 可以说这样的一个实现是myxml模型 现在我想强迫myxml模型以及其他所有实
  • 覆盖Java中的属性[重复]

    这个问题在这里已经有答案了 在 Java 中 我最近有几个项目 我使用了这样的设计模式 public abstract class A public abstract int getProperty public class B exten
  • 如何根据从 jtextfield 和组合框接收的值将数据行添加到 Jtable

    我有一个JFrame表格有JTextFields JCombobox等等 我能够将这些值接收到变量 现在我想将接收到的数据添加到JTable当用户单击 添加 或类似的操作时在新行中 我创造了JTable使用 net beans 的问题是将这
  • 从侦听器中修改 JFrame [重复]

    这个问题在这里已经有答案了 可能的重复 如何在框架可见后调用 setUndecorated https stackoverflow com questions 875132 how to call setundecorated after
  • 为什么 CompletableFuture 的 thenAccept() 不在主线程上运行

    我在 CompletableFuture 的 SupplyAsync 中处理长时间运行的操作 并将结果放入 thenAccept 中 有时 thenAccept 在主线程上执行 但有时它在工作线程上运行 但我只想在主线程上运行 thenAc
  • 为什么从类构造函数调用的方法应该是最终的? [复制]

    这个问题在这里已经有答案了 我是一名 Java 新手 我试图理解 Oracle 网站教程中的以下行 https docs oracle com javase tutorial java IandI final html https docs
  • Unix 纪元时间转 Java Date 对象

    我有一个包含以下内容的字符串UNIX 纪元时间 https en wikipedia org wiki Unix time 我需要将其转换为 Java Date 对象 String date 1081157732 DateFormat df
  • Zookeeper 未启动,nohup 错误

    我已经下载了zookeeper 3 4 5 tar gz 解压后我将conf zoo cfg写为 tickTime 2000 dataDir var zookeeper clientPort 2181 现在我尝试通过 bin zkServe
  • 在edittext android中插入imageview

    我想将 imageview 放在 edittext 中 可能吗 我检查了 evernote 应用程序 它能够将照片放在编辑文本部分 我想让我的应用程序完全相同 我如何才能将从图库中选择的图像视图放入编辑文本中 我首先尝试将 imagevie

随机推荐

  • 利用PostMan 模拟上传/下载文件

    我们经常用postman模拟各种http请求 但是有时候因为业务需要 我们需要测试上传下载功能 其实postman也是很好支持这两种操作的 一 上传文件 1 打开postman 选择对应request类型 以及url 2 选择body 单击
  • OkHttp3封装网络请求框架

    网络请求是开发中最基础的功能 框架原生API不便于复用 今天在这里分享慕课一位老师基于OkHttp封装的一个思路 希望对大家有帮助 首先 我们看一下Okhttp的基本使用 发送异步GET请求 1 new OkHttpClient 2 构造R
  • apt、apt-get、apt-cache使用详解

    文章目录 1 概述 2 搜索软件 查看软件信息 依赖关系 3 查看已安装软件 4 安装 升级软件 5 删除 6 清理 检查 7 忽略更新 8 apt get参数 9 参考文档 1 概述 apt apt get apt cache是三个软件
  • js修改数组中对象的key值

    不删除旧的key和value var data name 路口1 count 30 name 路口2 count 20 name 路口3 count 10 data data map item gt item value item coun
  • vue-router传参的四种方式超详细

    vue路由传参的四种方式 一 router link路由导航方式传参 父组件
  • 微服务优点缺点

    微服务架构采用Scale Cube方法设计应用架构 将应用服务按功能拆分成一组相互协作的服务 每个服务负责一组特定 相关的功能 每个服务可以有自己独立的数据库 从而保证与其他服务解耦 耦合是指两个或两个以上的体系或两种运动形式间通过相互作用
  • 移动端按设计图1:1布局方法

    1 为什么要写这篇教程 移动端布局大多数前端工程师使用的是百分比布局 然而百分比布局造成了很多问题 比如图片在不同分辨率下会有变形的问题 高度需要按照分辨率去兼容适配等等 今天给大家分享的这种布局方式 可以摈弃百分比布局 直接根据设计图1
  • 管道符和xargs

    先看一个例子 今天上了一门Linux课 其中有一道题是这样的 将文件 lib 目录下所有以包含 so的文件复制到cmd test目录下 一开始看到这个题 想法是先用find命令找出包含 so的文件 然后使用管道符cp 如下 find lib
  • robotstudio要从当前占位符中提取IRB2600....

    如上图所示 在添加singal后重启控制器便出现了这样的提示 找了一圈也没有找到答案 希望有高人指点指点
  • 关于8266WiFi模块(AT)问题分析与解答(单片机和wifi模块连接)

    近段时间由于作品需要 就入手了一个esp 01 s 8266wifi模块 厂家已经刷好固件 这个模块使用起来还是很简单便捷的 但是在调试过程中会遇到各种问题 以下是个人的一个总结 希望对大家有帮助 1 单片机晶振和波特率问题 重要 有关单片
  • 基于预测控制模型的自适应巡航控制仿真与机器人实现(Matlab代码实现)

    目录 1 概述 2 运行结果 3 参考文献 4 Matlab代码 1 概述 自适应巡航控制技术为目前由于汽车保有量不断增长而带来的行车安全 驾驶舒适性及交通拥堵等问题提供了一条有效的解决途径 因此本文通过理论分析 仿真验证及实车实验对自适应
  • 使用editor.md渲染markdown并自定义目录

    使用editor md渲染markdown并自定义目录 一 需求 最近在开发个人博客 在做文章详情页的时候 需要将markdown格式的文本字符串渲染成html页面 于是逛github的时候发现了这一款markdown在线编辑器 它支持将m
  • Json“牵手”亚马逊商品详情数据方法,亚马逊商品详情API接口,亚马逊API申请指南

    亚马逊平台是美国最大的一家网络电子商务公司 亚马逊公司是1995年成立 刚开始只做网上书籍售卖业务 后来扩展到了其他产品 现在已经是全世界商品品种最多的网上零售商和第二互联网公司 亚马逊是北美洲 欧洲等地区的主流购物平台 亚马逊商品分类接口
  • Office Visio 2007安装教程

    哈喽 大家好 今天一起学习的是Visio 2007的安装 这是一个绘制流程图的软件 用有效的绘图表达信息 比任何文字都更加形象和直观 Office Visio 是office软件系列中负责绘制流程图和示意图的软件 便于IT和商务人员就复杂信
  • SpringCloud与Dubbo的比较

    目录 Dubbo 一 dubbo简介 二 dubbo组织架构图 三 dubbo的优势 SpringCloud 一 SpringCloud简介 二 SpringCloud组织架构 三 SpringCloud特点 四 Dubbo与SpringC
  • 共模电感(扼流圈)选型

    1 共模电感原理 在介绍共模电感之前先介绍扼流圈 扼流圈是一种用来减弱电路里面高频电流的低阻抗线圈 为了提高其电感扼流圈通常有一软磁材料制的核心 共模扼流圈有多个同样的线圈 电流在这些线圈里反向流 因此在扼流圈的芯里磁场抵消 共模扼流圈常被
  • Python:打包生成.pyc、.pyd文件

    目录 pyd文件是什么 1 环境 2 待编译文件hello py以及setup py文件 3 运行调试 4 写在最后 pyd文件是什么 pyd文件类似于DLL 一般用C C 语言编译而成 可用作模块导入Python程序中 pyd文件仅适用于
  • 使用Unity游戏引擎在IOS模拟器中运行的方法

    在Unity编译IOS程序时 在Unity导航栏菜单中选择Edit gt ProjectSettings gt Player 菜单项 选择IOS平台在下方SDK Version处选择运行设备为IOS模拟器 选择完毕后Build and Ru
  • 任意代码执行漏洞简介

    一 任意代码执行漏洞思维导图 代码执行漏洞的成因 应用程序在调用一些能够将字符串转换为代码的函数 例如php中的eval中 没有考虑用户是否控制这个字符串 将造成代码执行漏洞 代码执行漏洞的常用函数 PHP eval assert preg
  • springcloud整合Hystrix

    作用 1 服务降级 触发情况 程序运行异常 超时 服务熔断触发服务降级 线程池 信号量打满也会触发服务降级 2 服务熔断 直接拒绝访问 即使有正确的访问也会短路 3 服务限流 排队有序进行 构建服务 1 建module provider h