diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/BladeApplication.java b/blade-core-launch/src/main/java/org/springblade/core/launch/BladeApplication.java index 781e9bc..089ef35 100644 --- a/blade-core-launch/src/main/java/org/springblade/core/launch/BladeApplication.java +++ b/blade-core-launch/src/main/java/org/springblade/core/launch/BladeApplication.java @@ -16,6 +16,7 @@ package org.springblade.core.launch; import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.launch.consul.ConsulConstant; import org.springblade.core.launch.service.LauncherService; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; @@ -91,6 +92,11 @@ public class BladeApplication { props.setProperty("blade.is-local", String.valueOf(isLocalDev())); props.setProperty("blade.dev-mode", profile.equals(AppConstant.PROD_CODE) ? "false" : "true"); props.setProperty("blade.service.version", AppConstant.APPLICATION_VERSION); + props.setProperty(ConsulConstant.CONSUL_HOST_KEY, profile.equals(AppConstant.DEV_CDOE) ? ConsulConstant.CONSUL_DEV_HOST : ConsulConstant.CONSUL_PROD_HOST); + props.setProperty(ConsulConstant.CONSUL_PORT_KEY, ConsulConstant.CONSUL_PORT); + props.setProperty(ConsulConstant.CONSUL_CONFIG_FORMAT_KEY, ConsulConstant.CONSUL_CONFIG_FORMAT); + props.setProperty(ConsulConstant.CONSUL_WATCH_DELAY_KEY, ConsulConstant.CONSUL_WATCH_DELAY); + props.setProperty(ConsulConstant.CONSUL_WATCH_ENABLED_KEY, ConsulConstant.CONSUL_WATCH_ENABLED); // 加载自定义组件 ServiceLoader loader = ServiceLoader.load(LauncherService.class); loader.forEach(launcherService -> launcherService.launcher(builder, appName, profile)); diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/consul/ConsulLauncherServiceImpl.java b/blade-core-launch/src/main/java/org/springblade/core/launch/consul/ConsulLauncherServiceImpl.java deleted file mode 100644 index 7431988..0000000 --- a/blade-core-launch/src/main/java/org/springblade/core/launch/consul/ConsulLauncherServiceImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). - *

- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.gnu.org/licenses/lgpl.html - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springblade.core.launch.consul; - -import org.springblade.core.launch.constant.AppConstant; -import org.springblade.core.launch.service.LauncherService; -import org.springframework.boot.builder.SpringApplicationBuilder; - -import java.util.Properties; - -/** - * consul启动拓展 - * - * @author Chill - */ -public class ConsulLauncherServiceImpl implements LauncherService { - - @Override - public void launcher(SpringApplicationBuilder builder, String appName, String profile) { - Properties props = System.getProperties(); - if (props.getProperty(ConsulConstant.CONSUL_HOST_KEY) == null) { - props.setProperty(ConsulConstant.CONSUL_HOST_KEY, profile.equals(AppConstant.DEV_CDOE) ? ConsulConstant.CONSUL_DEV_HOST : ConsulConstant.CONSUL_PROD_HOST); - } - if (props.getProperty(ConsulConstant.CONSUL_PORT_KEY) == null) { - props.setProperty(ConsulConstant.CONSUL_PORT_KEY, ConsulConstant.CONSUL_PORT); - } - props.setProperty(ConsulConstant.CONSUL_CONFIG_FORMAT_KEY, ConsulConstant.CONSUL_CONFIG_FORMAT); - props.setProperty(ConsulConstant.CONSUL_WATCH_DELAY_KEY, ConsulConstant.CONSUL_WATCH_DELAY); - props.setProperty(ConsulConstant.CONSUL_WATCH_ENABLED_KEY, ConsulConstant.CONSUL_WATCH_ENABLED); - } - -} diff --git a/blade-core-launch/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService b/blade-core-launch/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService deleted file mode 100644 index 35a20a7..0000000 --- a/blade-core-launch/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService +++ /dev/null @@ -1 +0,0 @@ -org.springblade.core.launch.consul.ConsulLauncherServiceImpl