Skip to content

Commit

Permalink
添加spring-cloud-bus支持,refresh存在bug
Browse files Browse the repository at this point in the history
  • Loading branch information
D2C-Cai committed Jan 5, 2019
1 parent 5cd18fc commit 375b003
Show file tree
Hide file tree
Showing 34 changed files with 79 additions and 643 deletions.
2 changes: 2 additions & 0 deletions attach/项目启动后的测试地址.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ http://192.168.5.20:2001/service-order-test.yml

http://192.168.5.20:2001/service-order-prd.yml

http://192.168.5.20:2001/actuator/bus-refresh POST

**#service-member**

http://192.168.5.20:8001/profile
Expand Down
8 changes: 8 additions & 0 deletions config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
45 changes: 27 additions & 18 deletions config-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
spring:
application:
name: config-server
profiles:
active: dev

---

# tomcat
server:
port: 2001

# eureka
eureka:
instance:
lease-expiration-duration-in-seconds: 30
lease-renewal-interval-in-seconds: 10
client:
service-url:
defaultZone: http://192.168.0.145:1001/eureka/

# actuator
management:
endpoints:
web:
exposure:
include: "bus-refresh"

# spring
spring:
profiles: dev
application:
name: config-server

# config
cloud:
config:
server:
git:
uri: https://github.com/D2C-Cai/mall-config.git

---

spring:
profiles: test

---

spring:
profiles: prd
# rabbitmq
rabbitmq:
host: 192.168.0.145
port: 5672
username: guest
password: guest
24 changes: 5 additions & 19 deletions erureka-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
spring:
application:
name: erureka-server
profiles:
active: dev

---

# tomcat
server:
port: 1001

# eureka
eureka:
instance:
hostname: 192.168.0.145
Expand All @@ -21,15 +15,7 @@ eureka:
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

# spring
spring:
profiles: dev

---

spring:
profiles: test

---

spring:
profiles: prd
application:
name: erureka-server
23 changes: 4 additions & 19 deletions mall-portal/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
spring:
application:
name: mall-portal
profiles:
active: dev

---

# tomcat
server:
port: 9001

Expand Down Expand Up @@ -60,15 +53,7 @@ zuul:
ignored-patterns: /service-*/**
sensitive-headers:

# spring
spring:
profiles: dev

---

spring:
profiles: test

---

spring:
profiles: prd
application:
name: mall-portal
8 changes: 4 additions & 4 deletions service-member/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>

<dependency>
<groupId>com.codingapi</groupId>
Expand Down Expand Up @@ -68,10 +72,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.d2c.member.business.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
public class ConfigCtrl {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.d2c.member.elasticsearch.repository.UserSearchRepository;
import com.d2c.member.mongodb.document.UserMongo;
import com.d2c.member.mongodb.repository.UserMongoRepository;
import com.d2c.member.rabbitmq.sender.DirectSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
Expand All @@ -29,16 +28,13 @@ public class UserServiceImpl implements UserService, ITxTransaction {
private UserMongoRepository userMongoRepository;
@Autowired
private UserSearchRepository userSearchRepository;
@Autowired
private DirectSender directSender;

@Override
public User findByName(String username) {
User user = userMapper.findByName(username);
redisTemplate.opsForValue().set("user_" + username, user);
userMongoRepository.save(new UserMongo(user));
userSearchRepository.save(new UserSearch(user));
//directSender.send(user);
return user;
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 375b003

Please sign in to comment.