java B2B2C源码电子商务平台 -commonservice-config配置服务搭建

news/2024/7/5 2:36:10

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Spring Cloud Config为分布式系统中的外部配置提供服务器和客户端支持。使用Config Server,您可以在所有环境中管理应用程序的外部属性。客户端和服务器上的概念映射与Spring Environment和PropertySource抽象相同,因此它们与Spring应用程序非常契合,但可以与任何以任何语言运行的应用程序一起使用。随着应用程序通过从开发人员到测试和生产的部署流程,您可以管理这些环境之间的配置,并确定应用程序具有迁移时需要运行的一切。服务器存储后端的默认实现使用git,因此它轻松支持标签版本的配置环境,以及可以访问用于管理内容的各种工具。很容易添加替代实现,并使用Spring配置将其插入。

需要JAVA Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码 一零三八七七四六二六
 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.ml.honghu</groupId><artifactId>commonservice</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>commonservice-config</artifactId><packaging>jar</packaging><name>commonservice-config</name><description>Config Server</description><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-eureka</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><id>1</id><goals><goal>repackage</goal></goals></execution><execution><id>2</id><goals><goal>build-info</goal></goals></execution></executions></plugin></plugins></build>
</project>

在src/main/java进行ConfigApplication.java启动文件配置:

 
package com.ml.honghu;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;@EnableConfigServer
@EnableEurekaClient
@SpringBootApplication
public class ConfigApplication {public static void main(String[] args) {SpringApplication.run(ConfigApplication.class, args);}
}

在src/main/resource下进行bootstrap.yml配置

 
server: 
port: 8888
spring:application:name: commonservice-config-serverprofiles:active: discovery,nativecloud:config:server:git:uri: http://192.168.0.254/honghu.../honghu-config.gitusername: honghupassword: 123456searchPaths: config-dev
security:basic:enabled: trueuser:name: honghupassword: 123456
eureka:client:serviceUrl:defaultZone: http://honghu:123456@localhost:8761/eureka/honghuZone: http://honghu:123456@localhost:8761/eureka/registry-fetch-interval-seconds: 300availability-zones:honghu: honghuZoneinstance:prefer-ip-address: truemetadataMap:version: 1.0variant: Auser: ${security.user.name}password: ${security.user.password}
management:security:enabled: false

注意: 如果不从远程git或者svn库加载配置文件信息,可以配置加载本地地址,比如window下配置使用:


server: 
port: 8888
spring:
application:name: commonservice-config-server
profiles:active: discovery,native
cloud:config:server:native.searchLocations: d:/honghu-config
security:
basic:enabled: true
user:name: honghupassword: 123456
eureka:
client:serviceUrl:defaultZone: http://honghu:123456@localhost:8761/eureka/honghuZone: http://honghu:123456@localhost:8761/eureka/registry-fetch-interval-seconds: 300availability-zones:honghu: honghuZone
instance:prefer-ip-address: truemetadataMap:version: 1.0variant: Auser: ${security.user.name}password: ${security.user.password}
management:
security:enabled: false

到此,整个config服务项目配置完毕
从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。

转载于:https://my.oschina.net/u/3873725/blog/3031730


http://lihuaxi.xjx100.cn/news/235877.html

相关文章

Ansible04-任务控制

目录 一、循环 二、条件 三、handlers 四、失败的处理 一、循环 使用 loop 关键字对一组项目迭代任务&#xff0c;循环变量 item 保存每个迭代过程中使用的值。 [studentworkstation ansible]$ vim loop.yml --- - name: Test loophosts: devgather_facts: novars:num:- …

383. Ransom Note/691. Stickers to Spell Word-- String, Map, back tracking-- 未完待续

383 easy 题&#xff0c;就是建立字母的hash 表 看第一个String 是否能被第二个String 所构建 canConstruct("aa", "aab") -> true 统计 第二个参数中每个字母的频率&#xff0c;可以用一个int[256] 建立hashmap, 然后统计 第一个String 中字母出现的…

你猜猜typeof (typeof 1) 会返回什么值(类型)?!

typeof typeof操作符返回一个字符串&#xff0c;表示未经计算的操作数的类型。 语法&#xff1a; var num a; console.log(typeof (num)); 或console.log(typeof num) 复制代码typeof 可以返回的类型为&#xff1a;number、string、boolean、undefined、null、object、functi…

Ansible05-部署文件

目录 一、部署文件的常用模块 二、使用jinja2文件部署自定义文件 一、部署文件的常用模块 部署文件常用模块有 file 创建、删除文件或目录&#xff0c;修改selinux上下文。copy 复制文件到受控节点上&#xff0c;也可以直接在受控结点上创建文件。fetch 从受控结点获取文件…

COMP 0137 Machine Vision

COMP 0137作业代做、Python实验作业代写、代做Python语言程序作业、代写Machine Vision作业COMP 0137 Machine Vision: Homework #1Due 19th November 2018 at 23:55pmWorth 10% of your overall gradeSubmit online, through MoodleFor this homework, we’ll revisit the pra…

BIML 101 - ETL数据清洗 系列 - BIML 快速入门教程 - 序

BIML 101 - BIML 快速入门教程 做大数据的项目&#xff0c;最花时间的就是数据清洗。 没有一个相对可靠的数据&#xff0c;数据分析就是无木之舟&#xff0c;无水之源。 如果你已经进了ETL这个坑&#xff0c;而且预算有限&#xff0c;并且有大量的活要做&#xff1b; 时间紧&am…

Spring事务管理的底层逻辑—源码解析

本文代码为spring 5.1.2spring是如何控制事务的提交和回滚 加上Transactional注解之后&#xff0c;Spring可以启到事务控制的功能了&#xff0c;再正式执行方法前它会做一些操作&#xff0c;我们来看看 首先进入CglibAopProxy.class的intercept方法或者JdkDynamicAopProxy.clas…

堡垒机高危命令正则表达式

堡垒机可以设置高危命令阻断&#xff0c;防止操作人员误操作造成删库跑路。但是什么是高危命令&#xff0c;需要管理员通过配置正则表达式&#xff0c;进行命令匹配。 今天2021年8月6日先匹配最常见的删库跑路命令 rm -rf / &#xff0c;以下几种表达式联合起来就可以阻断这类…