Browse Source

🎉 增加自定义命名空间的配置

test
smallchill 5 years ago
parent
commit
3608e996ee
  1. 5
      blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
  2. 3
      blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
  3. 8
      blade-service/blade-demo/src/test/java/launcher/DemoTestLauncherServiceImpl.java

5
blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java

@ -27,6 +27,11 @@ import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_
*/
public interface LauncherConstant {
/**
* nacos namespace id
*/
String NACOS_NAMESPACE = "f447a694-519a-4255-95f9-bcbb5a5d636";
/**
* nacos dev 地址
*/

3
blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java

@ -38,6 +38,9 @@ public class DemoLauncherServiceImpl implements LauncherService {
PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].data-id", NacosConstant.dataId("example", profile));
PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].group", NacosConstant.NACOS_CONFIG_GROUP);
PropsUtil.setProperty(props, "spring.cloud.nacos.config.ext-config[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH);
// 自定义命名空间
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
}
@Override

8
blade-service/blade-demo/src/test/java/launcher/DemoTestLauncherServiceImpl.java

@ -16,7 +16,7 @@
*/
package launcher;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.auto.service.AutoService;
import org.springblade.core.launch.service.LauncherService;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -34,9 +34,9 @@ public class DemoTestLauncherServiceImpl implements LauncherService {
@Override
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
Properties props = System.getProperties();
props.setProperty("spring.cloud.nacos.discovery.server-addr", CommonConstant.NACOS_DEV_ADDR);
props.setProperty("spring.cloud.nacos.config.server-addr", CommonConstant.NACOS_DEV_ADDR);
props.setProperty("spring.cloud.sentinel.transport.dashboard", CommonConstant.SENTINEL_DEV_ADDR);
props.setProperty("spring.cloud.nacos.discovery.server-addr", LauncherConstant.NACOS_DEV_ADDR);
props.setProperty("spring.cloud.nacos.config.server-addr", LauncherConstant.NACOS_DEV_ADDR);
props.setProperty("spring.cloud.sentinel.transport.dashboard", LauncherConstant.SENTINEL_DEV_ADDR);
}
@Override

Loading…
Cancel
Save