From ed598ba427036351027eaad55543e2968dcdcbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=81=E6=99=93=E6=B3=A2?= Date: Fri, 22 Nov 2019 17:49:26 +0800 Subject: [PATCH] add some warnings for classpath file datasource You could use absolute path when you use File datasource & fat jar. --- .../sentinel-core-example/readme.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-core-example/readme.md b/spring-cloud-alibaba-examples/sentinel-example/sentinel-core-example/readme.md index 8cc2f53e..01fcf7b2 100644 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-core-example/readme.md +++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-core-example/readme.md @@ -193,6 +193,18 @@ Now ReadableDataSource type support 5 categories: `file`, `nacos`, `zk`, `apollo If you want to use `nacos`, `zk`, `apollo` or `redis` ReadableDataSource, you could add `sentinel-datasource-nacos`, `sentinel-datasource-zookeeper`,`sentinel-datasource-apollo` or `sentinel-datasource-redis` dependency. +## warning +You should use `file` ReadableDataSource in a fatjar carefully or you may get error like this below + +``` +java.lang.RuntimeException: [Sentinel Starter] DataSource ds1 handle file [classpath: flowrule.json] error: class path resource [flowrule.json] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:xxx/xxx.jar!/BOOT-INF/classes!/flowrule.jso +``` +You could use absolute path when you use File datasource & fat jar. +It is recommended to use Nacos/Apollo/Zookeeper/Redis datasource to store rules. +https://github.com/alibaba/spring-cloud-alibaba/issues/428 + + + When ReadableDataSource load rule data successfully, console will print some logs: ``` @@ -203,4 +215,4 @@ When ReadableDataSource load rule data successfully, console will print some log ## More For more information about Sentinel, see [Sentinel Project](https://github.com/alibaba/Sentinel). -If you have any ideas or suggestions for Spring Cloud Sentinel starter, please don't hesitate to tell us by submitting github issues. \ No newline at end of file +If you have any ideas or suggestions for Spring Cloud Sentinel starter, please don't hesitate to tell us by submitting github issues.