-
Notifications
You must be signed in to change notification settings - Fork 211
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
Custom configuration #6
Comments
If we have multiple profiles, So I need to create multiple configuration classes. Like this: public class KafkaConfiguration extends AbstractCicadaConfiguration {
public KafkaConfiguration() {
super.setPropertiesName("kafka.properties");
}
}
public class RedisConfiguration extends AbstractCicadaConfiguration {
public RedisConfiguration() {
super.setPropertiesName("redis.properties");
}
} When I use: @Override
public WorkRes<DemoResVO> execute(Param paramMap) throws Exception {
KafkaConfiguration configuration = (KafkaConfiguration) getConfiguration(KafkaConfiguration.class);
RedisConfiguration redisConfiguration = (RedisConfiguration) ConfigurationHolder.getConfiguration(RedisConfiguration.class);
String brokerList = configuration.get("kafka.broker.list");
String redisHost = redisConfiguration.get("redis.host");
LOGGER.info("Configuration brokerList=[{}],redisHost=[{}]",brokerList,redisHost);
return res;
} Is there a better solution? |
如果约定好子类的命名规则,将这行代码
|
Great! I've thought about it before. But if you use it this way, we can not use like this:
This may not be consistent with the actual situation. And this class It feels a bit weird. |
why don't you put all |
application.properties: # default: kafka.properties(properties.A key mean defulat configuration file name is A.properties)
properties.kafka: xxxx.properties
properties.redis: redis1.properties
# all configuration files(code use split)
properties.all: kafka.properties, redis.properties and use maven profile deal dev/online/test env. |
Multiple profiles are for easy maintenance, similar to the By default, the configuration file under the classpath is read. In different environments, like this: -Dapplication.properties=/xx/application.properties
-Dkakfa.properties=/xx/kakfa.properties |
But I want to change the configuration in the |
haha, my company use # default active(mean dev and test dev use the same redis file)
properties.redis = redis.properties
# dev
dev.properties.kafka=kafka_dev.properties
# test
test.properties.kafka=kafka_test.properties code: |
大家都是中国人 为啥不说汉语 #滑稽 |
How to improve without self-restraint? |
@crossoverJie |
But |
so, how you plan the configuration way specific? Although it as a lightweight framework, also need support third-party components by the |
Prepare to do this. If there are good suggestions. raise a |
Describe the solution you'd like
The text was updated successfully, but these errors were encountered: