Skip to content

Commit

Permalink
Merge branch '1.0.7'
Browse files Browse the repository at this point in the history
# Conflicts:
#	spring-server/gateway-service/pom.xml
  • Loading branch information
web-xiaxia committed Jan 10, 2019
2 parents f1ae310 + e9c0fce commit 0eccae5
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 58 deletions.
10 changes: 0 additions & 10 deletions 0other/runConfigurations/EurekaBaseDemo1Application.xml

This file was deleted.

1 change: 1 addition & 0 deletions 0other/runConfigurations/ZuulServerApplication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<configuration default="false" name="ZuulServerApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" folderName="eureka">
<module name="zuul2-server" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.example.zuul2.demo.ZuulServerApplication" />
<option name="URL_PATH" value="/test_service/woaini/test" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2">
<option name="Make" enabled="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# demo配置服务名
demo1:
service:
serviceName: BASE-SERVICE-DEMO1
serviceName: base-service-demo1

6 changes: 0 additions & 6 deletions base-service/base-demo1-service/base-demo1-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!--ConfigurationProperties配置使用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!--自动注解配置-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import com.example.demo.base.demo1.contract.service.TestService;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
* @program: service1
Expand All @@ -22,6 +27,19 @@ public class TestServiceImpl implements TestService {

@Override
public String createToken(@RequestBody TestDemoModel model) {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();
String xxx = request.getHeader("xxx");
if(!StringUtils.isEmpty(xxx)){
System.out.println("获取到header xxx:"+xxx);
}

String xxx2 = request.getHeader("xxx2");
if(!StringUtils.isEmpty(xxx2)){
System.out.println("获取到header xxx2:"+xxx2);
}


return model.getTestText() + " 》》" + grayTitle;
}
}
6 changes: 0 additions & 6 deletions base-service/base-demo4-service/base-demo4-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!--ConfigurationProperties配置使用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!--自动注解配置-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# demo配置服务名
demo2:
service:
serviceName: BUSINESS-SERVICE-DEMO2
serviceName: business-demo-service

Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!--ConfigurationProperties配置使用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!--自动注解配置-->
<dependency>
Expand Down Expand Up @@ -84,10 +78,10 @@
</dependency>-->

<!--consul 灰度发布包-->
<dependency>
<!-- <dependency>
<groupId>com.labidc</groupId>
<artifactId>labidc-gray-deploy-consul</artifactId>
</dependency>
</dependency>-->

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.demo.business.demo2.service.service;



import com.example.demo.base.demo1.contract.feign.TestServiceImpl;
import com.example.demo.base.demo1.contract.model.TestDemoModel;
import com.example.demo.base.demo4.contract.feign.TestService4Impl;
Expand All @@ -12,9 +11,14 @@
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;


/**
Expand Down Expand Up @@ -42,6 +46,14 @@ public class Demo2ServiceImpl implements Demo2Service {
@Override
public String validate(@RequestBody Demo2Model model) {

ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();
String xxx = request.getHeader("xxx");
if(!StringUtils.isEmpty(xxx)){
System.out.println("获取到header xxx:"+xxx);
}
request.setAttribute("xxx2","xxxxx");

TestDemoModel testDemoModel = new TestDemoModel();
testDemoModel.setTestText(model.getDemo2Name() + " 》》" + grayTitle);
testService.createToken(testDemoModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
eureka:
instance:
prefer-ip-address: true
metadataMap:
metadata-map:
version: ${spring.gray.deploy.version:}
client:
registerWithEureka: true
registry-fetch-interval-seconds: 30
registry-fetch-interval-seconds: 3
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8766/eureka/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ server:
port: ${port:21000}

spring:
#gray:
# deploy:
# ribbonRule: RANDOM
gray:
deploy:
#ribbonRule: RANDOM
transmit:
headers:
- xxx
attributes:
- xxx2
application:
name: business-demo-service
sleuth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = "com.example.demo.business.demo2.service")
@EnableDiscoveryClient
public class ConsulBusinessDemoApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<!--consul 灰度发布包-->
<dependency>
<groupId>com.labidc</groupId>
<artifactId>labidc-gray-deploy-consul</artifactId>
<artifactId>labidc-gray-deploy-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = "com.example.demo.business.demo2.service")
@EnableDiscoveryClient
public class EurekaBusinessDemoApplication {

Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<commons-lang3.version>3.8.1</commons-lang3.version>
<commons-collections4.version>4.2</commons-collections4.version>

<labidc-gray-deploy.version>1.0.6</labidc-gray-deploy.version>
<labidc-gray-deploy.version>1.0.7</labidc-gray-deploy.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -250,6 +250,11 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<repositories>
Expand Down
6 changes: 0 additions & 6 deletions product-service/product-demo/product-demo-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!--ConfigurationProperties配置使用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!--自动注解配置-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

eureka:
instance:
prefer-ip-address: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ server:
spring:
gray:
deploy:
ribbonRule: RANDOM
#ribbonRule: RANDOM
transmit:
headers:
- xxx


application:
name: product-demo
sleuth:
Expand Down Expand Up @@ -57,6 +62,7 @@ ribbon:
ConnectTimeout: 10000
ReadTimeout: 20000
ServerListRefreshInterval: 5000
NFLoadBalancerPingInterval: 1



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.demo.product.web.config;

import org.springframework.context.annotation.Configuration;

/***
*
* @author xiongchuang
* @date 2018-01-15
*/
@Configuration
public class WebConfig {
//@Bean
//public IPing iPing(){
// return new PingUrl(false,"/actuator/health");
//}

}
16 changes: 10 additions & 6 deletions spring-server/gateway-service/pom.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>gateway-service</artifactId>
<packaging>jar</packaging>
<name>gateway-service</name>
<description>网关路由</description>

<parent>
<groupId>com.labidc.demo</groupId>
<artifactId>spring-server</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>gateway-service</artifactId>
<packaging>jar</packaging>

<name>gateway-service</name>
<description>网关路由</description>




<dependencies>

Expand Down
14 changes: 12 additions & 2 deletions spring-server/zuul2-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: ${port:8746}
port: ${port:8740}

spring:
gray:
Expand Down Expand Up @@ -31,7 +31,17 @@ zuul:
stripPrefix: true
serviceId: product-demo


hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 40000
ribbon:
ServerListRefreshInterval: 30000
ConnectTimeout: 10000
ReadTimeout: 20000

eureka:
instance:
Expand Down

0 comments on commit 0eccae5

Please sign in to comment.