<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 添加依賴 ```xml <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> ``` 完整版 ```xml <?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>cloudframe</artifactId> <groupId>com.gosuncn</groupId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>sys-provider</artifactId> <dependencies> <dependency> <groupId>com.gosuncn</groupId> <artifactId>common</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-oauth2</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> </dependencies> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>com/gosuncn/dao/*.xml</include> </includes> </resource> </resources> </build> </project> ``` # 修改配置文件 ```yaml spring: cloud: sentinel: transport: dashboard: 127.0.0.1:8080 ``` 完整版 ```yaml server: port: 8003 spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql:///provider?serverTimezone=UTC username: root password: root application: name: provider cloud: nacos: discovery: server-addr: 127.0.0.1:8848 sentinel: transport: dashboard: 127.0.0.1:8080 mybatis: mapper-locations: classpath*:/com/gosuncn/dao/*.xml cloudframe: public-key: public.cert ``` # 創建ProviderControllerBlockException ```java package com.gosuncn.controller; public class ProviderControllerBlockException { public static CommonResult findAll(BlockException exception) { return new CommonResult<>(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), "ProviderControllerBlockException"); } public CommonResult createProvider(BlockException exception) { return new CommonResult<>(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), "ProviderControllerBlockException"); } } ``` # 創建ProviderControllerThrowable ```java package com.gosuncn.controller; public class ProviderControllerThrowable { public static CommonResult findAll(Throwable exception) { return new CommonResult<>(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), "ProviderControllerThrowable"); } public CommonResult createProvider(Throwable exception) { return new CommonResult<>(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), "ProviderControllerThrowable"); } } ``` # 修改ProviderController ```java package com.gosuncn.controller; @RestController public class ProviderController { @Autowired private ProviderService providerService; @GetMapping("/") @SentinelResource(value = "findAll", fallbackClass = ProviderControllerThrowable.class, fallback = "findAll", blockHandlerClass = ProviderControllerBlockException.class, blockHandler = "findAll") public CommonResult findAll() { return new CommonResult<>(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), providerService.findAll().orElse(null)); } @GetMapping("/provider") @SentinelResource(value = "createProvider", fallbackClass = ProviderControllerThrowable.class, fallback = "createProvider", blockHandlerClass = ProviderControllerBlockException.class, blockHandler = "createProvider") public CommonResult createProvider() { Provider provider = new Provider(); provider.setName("Hi Girl."); return new CommonResult<>(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), providerService.createProvider(provider)); } } ``` # 消費者與提供者步驟相同 ##### 若需要支持feign需要修改application.properties ```properties feign.sentinel.enabled=true ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看