LauncherServiceImpl.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.common.launch;
  18. import org.springblade.common.constant.LauncherConstant;
  19. import org.springblade.core.auto.service.AutoService;
  20. import org.springblade.core.launch.service.LauncherService;
  21. import org.springblade.core.launch.utils.PropsUtil;
  22. import org.springframework.boot.builder.SpringApplicationBuilder;
  23. import java.util.Properties;
  24. /**
  25. * 启动参数拓展
  26. *
  27. * @author smallchil
  28. */
  29. @AutoService(LauncherService.class)
  30. public class LauncherServiceImpl implements LauncherService {
  31. @Override
  32. public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
  33. Properties props = System.getProperties();
  34. // 通用注册
  35. PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.server-addr", LauncherConstant.nacosAddr(profile));
  36. PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", LauncherConstant.nacosAddr(profile));
  37. PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile));
  38. PropsUtil.setProperty(props, "spring.zipkin.base-url", LauncherConstant.zipkinAddr(profile));
  39. PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "false");
  40. // 开启elk日志
  41. // PropsUtil.setProperty(props, "blade.log.elk.destination", LauncherConstant.elkAddr(profile));
  42. // seata注册地址
  43. // PropsUtil.setProperty(props, "seata.service.grouplist.default", LauncherConstant.seataAddr(profile));
  44. // seata注册group格式
  45. // PropsUtil.setProperty(props, "seata.tx-service-group", LauncherConstant.seataServiceGroup(appName));
  46. // seata配置服务group
  47. // PropsUtil.setProperty(props, "seata.service.vgroup-mapping.".concat(LauncherConstant.seataServiceGroup(appName)), LauncherConstant.DEFAULT_MODE);
  48. // seata注册模式配置
  49. // PropsUtil.setProperty(props, "seata.registry.type", LauncherConstant.NACOS_MODE);
  50. // PropsUtil.setProperty(props, "seata.registry.nacos.server-addr", LauncherConstant.nacosAddr(profile));
  51. // PropsUtil.setProperty(props, "seata.config.type", LauncherConstant.NACOS_MODE);
  52. // PropsUtil.setProperty(props, "seata.config.nacos.server-addr", LauncherConstant.nacosAddr(profile));
  53. }
  54. }