Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么不直接用 @Value 而是多增加一个配置文件 leaf.properties ? #137

Open
duandao1950 opened this issue Aug 13, 2020 · 0 comments

Comments

@duandao1950
Copy link

下面是示例 demo 是直接用 @value,共用 application.properties 或 apollo 配置,不用多增加一个额外的 leaf.properties 配置文件,而且不需要额外写读取 leaf.properties 配置的代码。
具体如下,测试可行:

public LeafSnowflakeService(@value("${leaf.snowflake.enable}") boolean leafSnowflakeEnable,
@value("${leaf.snowflake.zk.address}") String leafSnowflakeZkAddress,
@value("${leaf.snowflake.zk.port}") int leafSnowflakeZkPort) throws InitException {
if (leafSnowflakeEnable) {
idGen = new SnowflakeIDGenImpl(leafSnowflakeZkAddress, leafSnowflakeZkPort);
if (idGen.init()) {
log.info("Snowflake Service Init Successfully");
} else {
throw new InitException("Snowflake Service Init Fail");
}
} else {
idGen = new ZeroIDGen();
log.info("Zero ID Gen Service Init Successfully");
}
}

BTW:好像没找到 maven 包,哪里可以下载 jar 包?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant