Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
springcloud-sentinel
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
senthink-project-origin
springcloud-sentinel
Commits
f5179c08
Commit
f5179c08
authored
Apr 02, 2020
by
李根
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
写的是个锤子
parent
44c47fc1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
17 additions
and
39 deletions
+17
-39
sentinel-demo-springboot-nacos/pom.xml
+4
-24
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/config/AopConfiguration.java
+0
-1
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/config/ApplicationRunnerImpl.java
+3
-1
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/config/NacosStartService.java
+2
-3
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/controller/DemoController.java
+0
-6
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/inti/DemoNacosInitFunc.java
+5
-1
sentinel-demo-springboot-nacos/src/main/resources/META-INF/services/com.alibaba.csp.sentinel.init.InitFunc
+2
-0
sentinel-demo-springboot-nacos/src/main/resources/application.properties
+1
-1
sentinel-demo-springboot-nacos/src/main/resources/services/com.alibaba.csp.sentinel.init.InitFunc
+0
-2
No files found.
sentinel-demo-springboot-nacos/pom.xml
View file @
f5179c08
...
...
@@ -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>
...
...
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/config/AopConfiguration.java
View file @
f5179c08
...
...
@@ -30,5 +30,4 @@ public class AopConfiguration {
// return new SentinelResourceAspect();
// }
}
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/config/ApplicationRunnerImpl.java
View file @
f5179c08
...
...
@@ -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
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/config/NacosStartService.java
View file @
f5179c08
...
...
@@ -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
;
...
...
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/controller/DemoController.java
View file @
f5179c08
...
...
@@ -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"
)
...
...
sentinel-demo-springboot-nacos/src/main/java/com/alibaba/csp/sentinel/demo/springboot/nacos/inti/DemoNacosInitFunc.java
View file @
f5179c08
...
...
@@ -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
{
...
...
sentinel-demo-springboot-nacos/src/main/resources/META-INF/services/com.alibaba.csp.sentinel.init.InitFunc
0 → 100644
View file @
f5179c08
com.alibaba.csp.sentinel.demo.springboot.nacos.inti.DemoNacosInitFunc
\ No newline at end of file
sentinel-demo-springboot-nacos/src/main/resources/application.properties
View file @
f5179c08
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
...
...
sentinel-demo-springboot-nacos/src/main/resources/services/com.alibaba.csp.sentinel.init.InitFunc
deleted
100644 → 0
View file @
44c47fc1
com.alibaba.csp.sentinel.demo.springboot.nacos.init.DemoNacosInitFunc
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment