新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

JavaB2B2C多用户商城springboot架构——springcloud整合bus

bus的使用主要是配合springcloud config部分来一起使用,并没有单独使用

创新互联专注于企业成都全网营销推广、网站重做改版、当阳网站定制设计、自适应品牌网站建设、H5技术商城网站开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为当阳等各大城市提供网站开发制作服务。

首先建立服务端:


      org.springframework.cloud
      spring-cloud-config-server
    
    
      org.springframework.cloud
      spring-cloud-starter-bus-amqp

由于本次使用的是rabbitmq进行监听
了解springcloud架构可以加求求:三五三六二四七二五九
所以需要在依赖中引入amqp。这是rabbitmq采用的协议

server:
  port: 8080
spring:
  application:
    name: microservice-config-server
  cloud:
    config:
      server:
        git:
          uri: https://git.oschina.net/itmuch/spring-cloud-config-repo      # 配置Git仓库的地址
          username:                                                         # Git仓库的账号
          password:                                                         # Git仓库的密码
    bus:
      trace:
        enabled: true     # 开启cloud bus的跟踪
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
password: guest

然后再次配置连接,连接rabbitmq的地址

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
  public static void main(String[] args) {
    SpringApplication.run(ConfigServerApplication.class, args);
  }
}

再配置服务端:


      org.springframework.cloud
      spring-cloud-starter-config
    
    
    
      org.springframework.cloud
      spring-cloud-starter-bus-amqp

application.yml

server:
port: 8081

bootstrap.yml

复制代码
spring:
  application:
    name: microservice-foo    # 对应config server所获取的配置文件的{application}
  cloud:
    config:
      uri: http://localhost:8080/
      profile: dev            # profile对应config server所获取的配置文件中的{profile} 
      label: master           # 指定Git仓库的分支,对应config server所获取的配置文件的{label}
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
password: guest

分享文章:JavaB2B2C多用户商城springboot架构——springcloud整合bus
网页链接:http://www.wjwzjz.com/article/igispe.html
在线咨询
服务热线
服务热线:028-86922220
TOP