<modelVersion>4.0.0</modelVersion>
<artifactId>sys_config</artifactId>
<packaging>jar</packaging>
<name>config</name>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
</dependencies>
@SpringBootApplication
@EnableConfigServer//开启Config Server
@EnableEurekaClient
//@EnableDiscoveryClient//激活Eureka中的DiscoveryClient实现
public class ConfigApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigApplication.class, args);
}
}
git@github.com/401718154/springCloud.git
git config --global user.name "Your Real Name"
git config --global user.email you@email.address
ssh-keygen -C 'your@email.address' -t rsa
Account Settings-->SSH Public Keys-->Add another public key
git clone https://github.com/401718154/springCloud
git clone gti@github.com:401718154/springCloud.git
//git init
//创建文件夹及文件
git add .
git commit -m 'Test'
git remote add origin git@github.com:401718154/springCloud.git
git push -u origin master
from=git-default-1.0
from=git-dev-1.0
在master中,1.0后缀,另建一个configTest分支,2.0后缀。 git branch -a #查看远程分支
git branch #查看本地分支
git branch configTest #创建分支
git push origin configTest #把分支推到远程分支
git checkout configTest #切换分支到test
git branch -d xxxxx #删除本地分支
git remote -v #查看本地和远程分支
git push origin :br-1.0.0 #删除远程版本
git branch -r -d origin/branch-name #删除远程分支
git push origin :branch-name
git push -u origin configTest
spring.application.name=config-server
server.port=7001
eureka.client.serviceUrl.defaultZone=http://admin:123@localhost:1111/eureka/
eureka.instance.lease-expiration-duration-in-seconds=1
eureka.instance.lease-renewal-interval-in-seconds=1
#################################################################
#配置git仓库地址
#搜索位置,可配多个
spring.cloud.config.server.git.uri=https://github.com/wiootk/springCloud/
#配置仓库路径
spring.cloud.config.server.git.searchPaths=config
#配置仓库的分支 master/configTest
#spring.cloud.config.label=master
spring.cloud.config.server.git.username=401718154@qq.com
spring.cloud.config.server.git.password=215sos716
#通过服务来访问ConfigServer的功能
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.service-id=config
#################################################################
#本地存储配置
#spring.profiles.active=native
#默认从应用的src/main/resource目录下检索配置文件
#spring.cloud.config.server.native.searchLocations=file:F:/properties
#################################################################
#http://localhost:7001/didispace/from
#http请求地址和资源文件映射
#/{application}/{profile}[/{label}]
#/{application}-{profile}.yml
#/{label}/{application}-{profile}.yml
#/{application}-{profile}.properties
#/{label}/{application}-{profile}.properties
http://localhost:7001/didispace/dev/configTest
<!-- config 分布式配置中心-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
@RefreshScope
@RestController
class ConfigController {
private final Logger logger = Logger.getLogger(getClass());
// http://localhost:2222/from
// post http://localhost:2222/refresh 刷新数据
@Value("${from}")
private String from;
@RequestMapping("/from")
public String from() {
return this.from;
}
}
server.port=2222
#对应前配置文件中的{application}部分
spring.application.name=didispace
spring.cloud.config.discovery.serviceId=config-server
eureka.client.serviceUrl.defaultZone=http://admin:123@localhost:1111/eureka/
spring.cloud.config.discovery.enabled=true
#忽略权限拦截
management.security.enabled=false
#security.user.name=admin
#security.user.password=123
#management.security.enabled=true
#management.security.role=ADMIN
#刷新 http://localhost:2222/refresh
##############################
##远程仓库的分支
#对应前配置文件的git分支
spring.cloud.config.label=master
##dev/test/pro
#对应前配置文件中的{profile}部分
spring.cloud.config.profile=dev
#配置中心的地址
spring.cloud.config.uri= http://localhost:7001/
#对应的配置文件 didispace-dev.properties
注释或删除application.properties 相关配置
http://localhost:2222/from
http://localhost:2222/from
http://localhost:2222/refresh
刷新数据http://localhost:2222/from
消息代理中间件可以将消息路由到一个或多个目的地
先安装RabbitMQ
Erland
RabbitMQ
Rabbit管理
进入mq安装目录(sbin)执行rabbitmq-plugins enable rabbitmq_management
命令
(启动报错:将 C:\WINDOWS.erlang.cookie 同步到RabbitMq 启动用户C:\Users\%USERNAME%.erlang.cookie )
Web管理插件:http://localhost:15672/,用户guest,密码guest
<!-- 消息总线 amqp-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
spring.cloud.bus.trace.enabled=true
#忽略权限拦截
management.security.enabled=false
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=test
spring.rabbitmq.password=123456
#管理界面 http://localhost:15672/ guest guest
#刷新 http://localhost:2222/bus/refresh 指定服务刷新“/bus/refresh?destination=customers:**”
Kafka是一个由LinkedIn开发的分布式消息系统,Kafka是基于消息发布/订阅模式实现的消息系统,主要设计目标:消息持久化、高吞吐、分布式、跨平台、实时性、伸缩性
下载并解压kafka
启动ZooKeeper:zookeeper-server-start config/zookeeper.properties zookeeper.properties绑定2181端口
启动Kafka:kafka-server-start config/server.properties 配置文件中zookeeper.connect设置ZooKeeper的地址和端口,它默认会连接本地2181端口的ZooKeeper;设置多个ZooKeeper节点:zookeeper.connect=127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002
创建Topic:kafka-topics –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test
创建一个名为“test”的Topic,该Topic包含一个分区一个Replica。在创建完成后,可以使用kafka-topics –list –zookeeper localhost:2181命令来查看当前的Topic
创建消息生产者:kafka-console-producer –broker-list localhost:9092 –topic test
创建消息消费者:kafka-console-consumer –zookeeper localhost:2181 –topic test –from-beginning
2. 修改sys_config、sys_client配置文件
```properties
#kafka
spring.cloud.stream.kafka.binder.zk-nodes=localhost:2181
spring.cloud.stream.kafka.binder.brokers=localhost:9092
spring.cloud.bus.trace.enabled=true
.\bin\windows\kafka-server-start.bat .\config\server.properties
http://blog.csdn.net/derrantcm/article/details/73368538