Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0eccae5

Browse files
Merge branch '1.0.7'
# Conflicts: # spring-server/gateway-service/pom.xml
2 parents f1ae310 + e9c0fce commit 0eccae5

File tree

21 files changed

+103
-58
lines changed

21 files changed

+103
-58
lines changed

‎0other/runConfigurations/EurekaBaseDemo1Application.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎0other/runConfigurations/ZuulServerApplication.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<configuration default="false" name="ZuulServerApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" folderName="eureka">
33
<module name="zuul2-server" />
44
<option name="SPRING_BOOT_MAIN_CLASS" value="com.example.zuul2.demo.ZuulServerApplication" />
5+
<option name="URL_PATH" value="/test_service/woaini/test" />
56
<option name="ALTERNATIVE_JRE_PATH" />
67
<method v="2">
78
<option name="Make" enabled="true" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# demo配置服务名
22
demo1:
33
service:
4-
serviceName: BASE-SERVICE-DEMO1
4+
serviceName: base-service-demo1
55

‎base-service/base-demo1-service/base-demo1-base/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747
<artifactId>spring-boot-starter-actuator</artifactId>
4848
</dependency>
4949

50-
<!--ConfigurationProperties配置使用-->
51-
<dependency>
52-
<groupId>org.springframework.boot</groupId>
53-
<artifactId>spring-boot-configuration-processor</artifactId>
54-
<optional>true</optional>
55-
</dependency>
5650

5751
<!--自动注解配置-->
5852
<dependency>

‎base-service/base-demo1-service/base-demo1-base/src/main/java/com/example/demo/base/demo1/service/service/TestServiceImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
import com.example.demo.base.demo1.contract.service.TestService;
55
import lombok.extern.java.Log;
66
import org.springframework.beans.factory.annotation.Value;
7+
import org.springframework.util.StringUtils;
78
import org.springframework.web.bind.annotation.RequestBody;
89
import org.springframework.web.bind.annotation.RestController;
10+
import org.springframework.web.context.request.RequestContextHolder;
11+
import org.springframework.web.context.request.ServletRequestAttributes;
12+
13+
import javax.servlet.http.HttpServletRequest;
914

1015
/**
1116
* @program: service1
@@ -22,6 +27,19 @@ public class TestServiceImpl implements TestService {
2227

2328
@Override
2429
public String createToken(@RequestBody TestDemoModel model) {
30+
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
31+
HttpServletRequest request = requestAttributes.getRequest();
32+
String xxx = request.getHeader("xxx");
33+
if(!StringUtils.isEmpty(xxx)){
34+
System.out.println("获取到header xxx:"+xxx);
35+
}
36+
37+
String xxx2 = request.getHeader("xxx2");
38+
if(!StringUtils.isEmpty(xxx2)){
39+
System.out.println("获取到header xxx2:"+xxx2);
40+
}
41+
42+
2543
return model.getTestText() + " 》》" + grayTitle;
2644
}
2745
}

‎base-service/base-demo4-service/base-demo4-base/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747
<artifactId>spring-boot-starter-actuator</artifactId>
4848
</dependency>
4949

50-
<!--ConfigurationProperties配置使用-->
51-
<dependency>
52-
<groupId>org.springframework.boot</groupId>
53-
<artifactId>spring-boot-configuration-processor</artifactId>
54-
<optional>true</optional>
55-
</dependency>
5650

5751
<!--自动注解配置-->
5852
<dependency>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# demo配置服务名
22
demo2:
33
service:
4-
serviceName: BUSINESS-SERVICE-DEMO2
4+
serviceName: business-demo-service
55

‎business-service/business-demo-service/business-demo-base/pom.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545
<artifactId>spring-boot-starter-actuator</artifactId>
4646
</dependency>
4747

48-
<!--ConfigurationProperties配置使用-->
49-
<dependency>
50-
<groupId>org.springframework.boot</groupId>
51-
<artifactId>spring-boot-configuration-processor</artifactId>
52-
<optional>true</optional>
53-
</dependency>
5448

5549
<!--自动注解配置-->
5650
<dependency>
@@ -84,10 +78,10 @@
8478
</dependency>-->
8579

8680
<!--consul 灰度发布包-->
87-
<dependency>
81+
<!-- <dependency>
8882
<groupId>com.labidc</groupId>
8983
<artifactId>labidc-gray-deploy-consul</artifactId>
90-
</dependency>
84+
</dependency>-->
9185

9286
</dependencies>
9387

‎business-service/business-demo-service/business-demo-base/src/main/java/com/example/demo/business/demo2/service/service/Demo2ServiceImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.example.demo.business.demo2.service.service;
22

33

4-
54
import com.example.demo.base.demo1.contract.feign.TestServiceImpl;
65
import com.example.demo.base.demo1.contract.model.TestDemoModel;
76
import com.example.demo.base.demo4.contract.feign.TestService4Impl;
@@ -12,9 +11,14 @@
1211
import lombok.extern.java.Log;
1312
import org.springframework.beans.factory.annotation.Autowired;
1413
import org.springframework.beans.factory.annotation.Value;
14+
import org.springframework.util.StringUtils;
1515
import org.springframework.web.bind.annotation.RequestBody;
1616
import org.springframework.web.bind.annotation.RequestMapping;
1717
import org.springframework.web.bind.annotation.RestController;
18+
import org.springframework.web.context.request.RequestContextHolder;
19+
import org.springframework.web.context.request.ServletRequestAttributes;
20+
21+
import javax.servlet.http.HttpServletRequest;
1822

1923

2024
/**
@@ -42,6 +46,14 @@ public class Demo2ServiceImpl implements Demo2Service {
4246
@Override
4347
public String validate(@RequestBody Demo2Model model) {
4448

49+
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
50+
HttpServletRequest request = requestAttributes.getRequest();
51+
String xxx = request.getHeader("xxx");
52+
if(!StringUtils.isEmpty(xxx)){
53+
System.out.println("获取到header xxx:"+xxx);
54+
}
55+
request.setAttribute("xxx2","xxxxx");
56+
4557
TestDemoModel testDemoModel = new TestDemoModel();
4658
testDemoModel.setTestText(model.getDemo2Name() + " 》》" + grayTitle);
4759
testService.createToken(testDemoModel);

‎business-service/business-demo-service/business-demo-base/src/main/resources/application-eureka.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
eureka:
33
instance:
44
prefer-ip-address: true
5-
metadataMap:
5+
metadata-map:
66
version: ${spring.gray.deploy.version:}
77
client:
88
registerWithEureka: true
9-
registry-fetch-interval-seconds: 30
9+
registry-fetch-interval-seconds: 3
1010
fetchRegistry: true
1111
serviceUrl:
1212
defaultZone: http://localhost:8766/eureka/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /