idea创建springcloud项目图文教程(bus 消息总线)(十二)

 

1,pom.xml的配置文件



	4.0.0

	
        
		com.hcmony
		springcloud
		0.0.1-SNAPSHOT
	

	config-bus
	pom

	
		UTF-8
		UTF-8
		1.8
	

	
		
			org.springframework.cloud
			spring-cloud-starter-config
			RELEASE
		
		
			org.springframework.cloud
			spring-cloud-starter-bus-amqp
			RELEASE
		
		
			org.springframework.boot
			spring-boot-starter-actuator
		
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	



2,启动类

package com.hcmony;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
@SpringBootApplication
public class BusApplication {

	public static void main(String[] args) {
		SpringApplication.run(BusApplication.class, args);
	}

	@Value("${bus}")
	private String bus;

	@RequestMapping("/bus")
	public String test(){
		return bus;
	}
}

3,bootstrap.properties 配置文件

spring.application.name=config-bus
spring.cloud.config.label=master
spring.cloud.config.profile=dev
spring.cloud.config.uri=http://localhost:8095/
server.port=8097

eureka.client.service-url.defaultZone= http://localhost:8888/eureka/

4,application.properties 配置文件

spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

spring.cloud.bus.enabled=true
spring.cloud.bus.trace.enabled=true
management.endpoints.web.exposure.include=bus-refresh

springcloud 源代码 https://github.com/hcmony/springcloud.git

idea创建maven项目,本教程适合各类小白(一)

idea创建maven,spring,springmvc,mybatis,项目(二) 

idea创建maven,spring,springmvc,mybatis,项目(三)

idea创建springboot项目图文教程(四)

idea创建springboot项目图文教程(配置文件)(五)

idea创建springcloud项目图文教程(EurekaServer注册中心)(六)

idea创建springcloud项目图文教程(创建服务提供者)(七)

idea创建springcloud项目图文教程(创建消费者)(八)

idea创建springcloud项目图文教程(Feign实现负载均衡)(九)

idea创建springcloud项目图文教程(config 实现配置中心)(十一)

idea创建springcloud项目图文教程(bus 消息总线)(十二)

 

你可能感兴趣的:(分布式服务,SpringCloud)