国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案

SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案

2021-05-28 13:19zjh_746140129 Java教程

這篇文章主要介紹了SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

hystrix參數使用方法

通過注解@hystrixcommand的commandproperties去配置,

如下就是hystrix命令超時時間命令執行超時時間,為1000ms和執行是不啟用超時

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@restcontroller
public class moviecontroller {
@autowired
private resttemplate resttemplate;
 
@getmapping("/movie/{id}")
@hystrixcommand(commandproperties = {
@hystrixproperty(name = "execution.isolation.thread.timeoutinmilliseconds", value = "1000"),
@hystrixproperty(name = "execution.timeout.enabled", value = "false")},fallbackmethod = "findbyidfallback")
public user findbyid(@pathvariable long id) {
return this.resttemplate.getforobject("http://microservice-provider-user/simple/" + id, user.class);
}
 
/**
* fallback方法
* @param id
* @return
*/
public user findbyidfallback(long id) {
user user = new user();
user.setid(5l);
return user;
}
}

問題描述:

筆者在使用spring boot 2.0整合spring cloud finchley.rc2版本時,使用斷路器 hystrix時候發現@hystrixcommand注解找不到,由于spring boot 2.0剛出沒多久,所以這塊資料網上很少,查閱資料說是新版本中不包含此注解了,需要重新引入。

報錯信息:

SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案

源碼:

SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案

SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案

SpringBoot2.0整合SpringCloud Finchley @hystrixcommand注解找不到解決方案

解決方案:pom.xml添加依賴

?
1
2
3
4
5
<dependency>
 <groupid>com.netflix.hystrix</groupid>
  <artifactid>hystrix-javanica</artifactid>
  <version>release</version>
</dependency>

完整pom.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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">
  <modelversion>4.0.0</modelversion>
  <groupid>com.serverribbon</groupid>
  <artifactid>serverribbon</artifactid>
  <version>0.0.1-snapshot</version>
  <packaging>jar</packaging>
 
  <name>serverribbon</name>
  <description>demo project for spring boot</description>
 
  <parent>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-starter-parent</artifactid>
   <version>2.0.2.release</version>
   <relativepath/> <!-- lookup parent from repository -->
  </parent>
 
  <properties>
   <project.build.sourceencoding>utf-</project.build.sourceencoding>
   <project.reporting.outputencoding>utf-</project.reporting.outputencoding>
   <java.version>1.8</java.version>
   <spring-cloud.version>finchley.rc2</spring-cloud.version>
  </properties>
 
  <dependencies>
   <dependency>
     <groupid>org.springframework.cloud</groupid>
     <artifactid>spring-cloud-starter-netflix-eureka-server</artifactid>
   </dependency>
 
   <dependency>
     <groupid>org.springframework.cloud</groupid>
     <artifactid>spring-cloud-starter-ribbon</artifactid>
   </dependency>
 
   <dependency>
     <groupid>org.springframework.cloud</groupid>
     <artifactid>spring-cloud-starter-hystrix</artifactid>
   </dependency>
 
   <dependency>
     <groupid>com.netflix.hystrix</groupid>
     <artifactid>hystrix-javanica</artifactid>
     <version>release</version>
   </dependency>
 
   <dependency>
     <groupid>org.springframework.boot</groupid>
     <artifactid>spring-boot-starter-test</artifactid>
     <scope>test</scope>
   </dependency>
   <dependency>
     <groupid>com.netflix.hystrix</groupid>
     <artifactid>hystrix-core</artifactid>
     <version>release</version>
   </dependency>
    <dependency>
      <groupid>com.netflix.hystrix</groupid>
      <artifactid>hystrix-core</artifactid>
      <version>release</version>
    </dependency>
  </dependencies>
 
  <dependencymanagement>
   <dependencies>
     <dependency>
      <groupid>org.springframework.cloud</groupid>
      <artifactid>spring-cloud-dependencies</artifactid>
      <version>${spring-cloud.version}</version>
      <type>pom</type>
      <scope>import</scope>
     </dependency>
   </dependencies>
  </dependencymanagement>
 
  <build>
   <plugins>
     <plugin>
      <groupid>org.springframework.boot</groupid>
      <artifactid>spring-boot-maven-plugin</artifactid>
     </plugin>
   </plugins>
  </build>
 
  <repositories>
   <repository>
     <id>spring-milestones</id>
     <name>spring milestones</name>
     <url>https://repo.spring.io/milestone</url>
     <snapshots>
      <enabled>false</enabled>
     </snapshots>
   </repository>
  </repositories>
 
 
</project>

在程序的啟動類serviceribbonapplication 加@enablehystrix注解開啟hystrix

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:https://blog.csdn.net/zjh_746140129/article/details/80697921

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日韩小视频在线观看 | 在线免费观看中文字幕 | av免费观看网站 | 久久久国产精品免费观看 | 日韩精品一区二区三区中文字幕 | 欧美日韩亚洲国产精品 | 国产精品视频入口 | 精品成人免费 | 国产精品视频久久久 | 在线观看成人 | 色网综合| 91视频入口| 一区影院| 91在线免费视频 | 免费一级片在线 | 欧美一级二级三级视频 | 精品视频网| 免费精品视频 | 色婷婷av一区二区三区大白胸 | 午夜国产视频 | 色噜噜视频在线观看 | 在线黄色网 | 免费在线看污网站 | 女人久久久久 | xvideos.蜜桃一区二区 | 一区二区三区在线播放 | 亚洲欧美在线观看 | 免费黄色大片 | 亚洲骚片 | 超碰一区二区 | 国产精品18久久久久久久久久久久 | 无码一区二区三区视频 | 国产精品久久久久久久午夜片 | 亚洲一区二区三区免费视频 | 狠狠色狠狠色合久久伊人 | 亚洲一区二区三区高清 | 欧美激情综合五月色丁香小说 | 日韩 在线 | 亚洲精品一区二三区不卡 | 久久a国产 | 亚洲精品一区二区三区不 |