Commit f5179c08 by 李根

写的是个锤子

parent 44c47fc1
......@@ -16,15 +16,11 @@
</properties>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.csp</groupId>-->
<!-- <artifactId>sentinel-core</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.csp</groupId>-->
<!-- <artifactId>sentinel-annotation-aspectj</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-transport-simple-http</artifactId>
......@@ -34,26 +30,10 @@
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-extension</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.csp</groupId>-->
<!-- <artifactId>sentinel-extension</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-aop</artifactId>-->
<!-- <version>${spring.boot.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
......@@ -30,5 +30,4 @@ public class AopConfiguration {
// return new SentinelResourceAspect();
// }
}
......@@ -15,8 +15,9 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
@Autowired
private NacosStartService nacosStartService;
@Override
public void run(ApplicationArguments args) throws Exception {
nacosStartService.initNacosConfigFromNacos();
// nacosStartService.initNacosConfigFromNacos();
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.context.annotation.Configuration;
import java.util.List;
import java.util.Objects;
......@@ -26,12 +26,11 @@ import java.util.Properties;
* @description:
* @date 2020/4/214:08
*/
@Service
@Configuration
public class NacosStartService {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private SentinelProperties sentinelProperties;
......
......@@ -15,12 +15,10 @@
*/
package com.alibaba.csp.sentinel.demo.springboot.nacos.controller;
import com.alibaba.cloud.sentinel.SentinelProperties;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -35,10 +33,6 @@ public class DemoController {
Logger logger = LoggerFactory.getLogger(DemoController.class);
@Autowired
private SentinelProperties sentinelProperties;
@Order(1)
@SentinelResource(value = "test1", blockHandler = "myBlockHandler", fallbackClass = FallBack.class, fallback = "test1FallBack")
@GetMapping("/test1")
......
......@@ -12,8 +12,12 @@ import org.springframework.stereotype.Component;
@Component
public class DemoNacosInitFunc implements InitFunc {
/*
* 因为sentinel是SPI拓展接口不能使用,spring的ioc,所以下面的注入会报NPE。。。。
* */
@Autowired
private NacosStartService nacosStartService;
NacosStartService nacosStartService;
@Override
public void init() throws Exception {
......
com.alibaba.csp.sentinel.demo.springboot.nacos.inti.DemoNacosInitFunc
\ No newline at end of file
spring.application.name=springboot-nacos
server.port=19966
spring.cloud.sentinel.transport.dashboard=127.0.0.1:8080
# ʽ1
spring.cloud.sentinel.datasource.ds3.nacos.server-addr=10.16.10.139:8848
spring.cloud.sentinel.datasource.ds3.nacos.dataId=springboot-nacos-flow-rules
spring.cloud.sentinel.datasource.ds3.nacos.groupId=DEFAULT_GROUP
......
com.alibaba.csp.sentinel.demo.springboot.nacos.init.DemoNacosInitFunc
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment