mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-12-12 12:19:27 +08:00
⚡ 集成nacos
This commit is contained in:
parent
8222bcac25
commit
42026bcb95
@ -57,16 +57,14 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -16,7 +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.constant.NacosConstant;
|
||||
import org.springblade.core.launch.service.LauncherService;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@ -92,11 +92,10 @@ 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("spring.cloud.consul.host", ConsulConstant.CONSUL_HOST);
|
||||
props.setProperty("spring.cloud.consul.port", ConsulConstant.CONSUL_PORT);
|
||||
props.setProperty("spring.cloud.consul.config.format", ConsulConstant.CONSUL_CONFIG_FORMAT);
|
||||
props.setProperty("spring.cloud.consul.watch.delay", ConsulConstant.CONSUL_WATCH_DELAY);
|
||||
props.setProperty("spring.cloud.consul.watch.enabled", ConsulConstant.CONSUL_WATCH_ENABLED);
|
||||
props.setProperty("spring.cloud.nacos.discovery.server-addr", NacosConstant.NACOS_ADDR);
|
||||
props.setProperty("spring.cloud.nacos.config.server-addr", NacosConstant.NACOS_ADDR);
|
||||
props.setProperty("spring.cloud.nacos.config.prefix", NacosConstant.NACOS_CONFIG_PREFIX);
|
||||
props.setProperty("spring.cloud.nacos.config.file-extension", NacosConstant.NACOS_CONFIG_FORMAT);
|
||||
// 加载自定义组件
|
||||
ServiceLoader<LauncherService> loader = ServiceLoader.load(LauncherService.class);
|
||||
loader.forEach(launcherService -> launcherService.launcher(builder, appName, profile));
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.launch.consul;
|
||||
package org.springblade.core.launch.constant;
|
||||
|
||||
/**
|
||||
* Consul常量.
|
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* 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.constant;
|
||||
|
||||
/**
|
||||
* Nacos常量.
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface NacosConstant {
|
||||
|
||||
/**
|
||||
* nacos 地址
|
||||
*/
|
||||
String NACOS_ADDR = "127.0.0.1:8848";
|
||||
|
||||
/**
|
||||
* nacos 配置前缀
|
||||
*/
|
||||
String NACOS_CONFIG_PREFIX = "blade";
|
||||
|
||||
/**
|
||||
* nacos 配置文件类型
|
||||
*/
|
||||
String NACOS_CONFIG_FORMAT = "yaml";
|
||||
}
|
1
pom.xml
1
pom.xml
@ -49,6 +49,7 @@
|
||||
<disruptor.version>3.4.2</disruptor.version>
|
||||
<spring.boot.admin.version>2.0.2</spring.boot.admin.version>
|
||||
<mica.auto.version>1.0.1</mica.auto.version>
|
||||
<nacos.version>0.2.1.RELEASE</nacos.version>
|
||||
|
||||
<spring.boot.version>2.0.7.RELEASE</spring.boot.version>
|
||||
<spring.cloud.version>Finchley.SR2</spring.cloud.version>
|
||||
|
Loading…
Reference in New Issue
Block a user