Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
com.dangdang:config-toolkit
Advanced tools
Tool to simplify read configurations form zookeeper/file/http in Java
Config Toolkit提供了一层对配置资源的抽象,配置可以从多种介质加载,工具内部提供了对zookeeper/本地文件/远程http文件的支持,并提供了SPI接口支持用户扩展自定义介质
文档: https://github.com/dangdangdotcom/config-toolkit/wiki
Release Note: https://github.com/dangdangdotcom/config-toolkit/wiki/1.-release-notes
docker run -it -d -e "zk=localhost:2181" -p 8080:8080 crnlmchina/config-face:v3.3.0
git clone https://github.com/dangdangdotcom/config-toolkit.git
cd config-toolkit/config-face
mvn package
java -jar config-face.jar --zk=localhost:2181
使用命令行创建zookeeper配置根节点,根节点密码使用sha1加密,如果要使用明文密码,可以自行修改config-zk-web的鉴权部分代码
以根路径为/projectx/modulex
密码为abc
为例
python -c "import hashlib;print hashlib.sha1('abc').hexdigest();"
# a9993e364706816aba3e25717850c26c9cd0d89d
zkCli.sh -server localhost:2181
create /projectx 1
create /projectx/modulex a9993e364706816aba3e25717850c26c9cd0d89d
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>config-toolkit</artifactId>
<version>3.3.2-RELEASE</version>
</dependency>
ZookeeperConfigProfile configProfile = new ZookeeperConfigProfile("localhost:2181", "/projectx/modulex", "1.0.0");
GeneralConfigGroup group = new ZookeeperConfigGroup(configProfile, "group");
String stringProperty = group.get("config.str");
Preconditions.checkState("hello".equals(stringProperty));
String intProperty = group.get("config.int");
Preconditions.checkState(7758 == Integer.parseInt(intProperty));
spring xml schema
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config="https://crnlmchina.github.io/config"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
https://crnlmchina.github.io/config https://crnlmchina.github.io/config/config.xsd">
bean配置
<config:profile connect-str="localhost:2181" root-node="/projectx/modulex"
version="1.0.0"/>
<config:placeholder>
<config:group node="property-group1" />
<config:group node="property-group2" />
</config:placeholder>
<!-- Your business bean -->
<bean class="your.BusinessBean">
<property name="strProp" value="${config.str}" />
<property name="intProp" value="${config.int}" />
</bean>
由于spring对多个placeholder的支持不太好,需要仔细配置order,所以建议使用SPEL方式来配置
<config:profile connect-str="localhost:2181" root-node="/projectx/modulex" version="1.0.0"/>
<config:group id="groupProp" node="group"/>
<!-- Your business bean -->
<bean class="your.BusinessBean">
<property name="strProp" value="#{groupProp['config.str']}" />
<property name="intProp" value="#{groupProp['config.int']}" />
</bean>
如果您已经读到这儿了,辛苦回到页首给项目点个star吧,让更多的人可以关注到它 -_-
FAQs
Tool to simplify read configurations form zookeeper/file/http in Java
We found that com.dangdang:config-toolkit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.