在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:smarten开源软件地址:https://gitee.com/abocode-source/smarten开源软件介绍:smarten高性能的分布式配置管理中心
HOW 怎么使用:
在项目中smarten-server-web运行SmartenServer.java HOW 项目中集成:
<dependency> <groupId>com.abocode.smarten</groupId> <artifactId>smarten-client</artifactId> <version>${project.parent.version}</version> </dependency> 方式一:spring mvc Controller @Slf4j @RestController @RequestMapping("/tests") public class HelloController { @Autowired private Properties properties; @Value(" ${string}") private String val; @GetMapping public String hello() { return properties.getProperty("string"); } } 方式二 String host="127.0.0.1"; int port=5555; String projectCode="smarten"; String moduleCodes="smarten-test"; //多个用逗号隔开 String profile="development"; ClientProperties clientProperties = new ClientProperties(host,port,projectCode,moduleCodes,profile); clientProperties.addConfigurationListener(new ConfigTestListener()); for (int i=0;i<100000;i++){ Thread.sleep(2000); System.out.println(clientProperties.getString("string")); } 方式三:spring boot @Bean public Properties properties() { String host="127.0.0.1"; int port=5555; String projectCode="smarten"; String moduleCodes="smarten-test"; //多个用逗号隔开 String profile="development"; return new ClientProperties(host,port,projectCode,moduleCodes,profile).getProperties(); } @Bean public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){ PropertySourcesPlaceholderConfigurer bean=new PropertySourcesPlaceholderConfigurer(); bean.setProperties(properties()); return bean; } Rest 接口获取配置:配置信息: http://127.0.0.1:7077/swagger-ui.html 测试链接: |
请发表评论