Skip to content

Commit

Permalink
change project to Spring Cloud using spring cloud huawei
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 committed Sep 2, 2021
1 parent 3165d44 commit 36b3b21
Show file tree
Hide file tree
Showing 18 changed files with 292 additions and 155 deletions.
85 changes: 85 additions & 0 deletions hsf-pandora-boot/hsf-pandora-boot-api/pom.xml
@@ -0,0 +1,85 @@
<?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>

<parent>
<groupId>com.alibaba.edas</groupId>
<artifactId>hsf-pandora-boot-parent</artifactId>
<version>1.0</version>
</parent>

<artifactId>hsf-pandora-boot-api</artifactId>

<properties>
<spring-boot.version>2.5.3</spring-boot.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<spring-cloud-huawei.version>1.6.1-2020.0.x</spring-cloud-huawei.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>spring-cloud-starter-huawei-service-engine</artifactId>
</dependency>

<!-- for unit test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>spring-cloud-huawei-bom</artifactId>
<version>${spring-cloud-huawei.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>


</project>
@@ -0,0 +1,12 @@
package com.alibaba.edas;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

public interface HelloService {
@PostMapping(value = "/echo")
@ResponseBody
String echo(@RequestParam("name") String string);
}
57 changes: 28 additions & 29 deletions hsf-pandora-boot/hsf-pandora-boot-consumer/pom.xml
Expand Up @@ -4,35 +4,40 @@
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>

<groupId>com.alibaba.edas</groupId>
<parent>
<groupId>com.alibaba.edas</groupId>
<artifactId>hsf-pandora-boot-parent</artifactId>
<version>1.0</version>
</parent>

<artifactId>hsf-pandora-boot-consumer</artifactId>
<version>1.0</version>

<properties>
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
<pandora-boot.version>2019-06-stable</pandora-boot.version>
<spring-boot.version>2.5.3</spring-boot.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<spring-cloud-huawei.version>1.6.1-2020.0.x</spring-cloud-huawei.version>
</properties>

<dependencies>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>pandora-hsf-spring-boot-starter</artifactId>
<groupId>com.alibaba.edas</groupId>
<artifactId>hsf-pandora-boot-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.taobao.pandora</groupId>
<artifactId>taobao-hsf.sar</artifactId>
<groupId>com.huaweicloud</groupId>
<artifactId>spring-cloud-starter-huawei-service-engine</artifactId>
</dependency>

<!-- for unit test-->
<dependency>
<groupId>com.taobao.pandora</groupId>
<artifactId>pandora-boot-test</artifactId>
<scope>test</scope>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

<!-- for unit test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -50,9 +55,16 @@
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.taobao.pandora</groupId>
<artifactId>pandora-boot-starter-bom</artifactId>
<version>${pandora-boot.version}</version>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>spring-cloud-huawei-bom</artifactId>
<version>${spring-cloud-huawei.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -70,19 +82,6 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.taobao.pandora</groupId>
<artifactId>pandora-boot-maven-plugin</artifactId>
<version>2.1.11.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
@@ -1,17 +1,17 @@
package com.alibaba.edas;

import com.taobao.pandora.boot.PandoraBootstrap;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(clients= {HelloServiceFeignClient.class})
public class HSFConsumerApplication {

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

}

This file was deleted.

@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.edas;

import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "hsf-pandora-boot-provider", contextId = "helloServiceFeignClient", path = "/hello")
public interface HelloServiceFeignClient extends HelloService {
}

This file was deleted.

Expand Up @@ -12,10 +12,10 @@ public class SimpleController {


@Autowired
private HelloService helloService;
private HelloServiceFeignClient helloServiceFeignClient;

@RequestMapping(value = "/hsf-echo/{str}", method = RequestMethod.GET)
public String echo(@PathVariable String str) {
return helloService.echo(str);
return helloServiceFeignClient.echo(str);
}
}
@@ -1,4 +1,4 @@
spring.application.name=hsf-pandora-boot-consumer
# spring.application.name=hsf-pandora-boot-consumer
server.port=8086
spring.hsf.version=1.0.0
spring.hsf.timeout=1000
@@ -0,0 +1,40 @@
#
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
spring:
application:
name: hsf-pandora-boot-consumer
cloud:
servicecomb:
discovery:
enabled: true
# address: https://cse.cn-south-1.myhuaweicloud.com
address: http://127.0.0.1:30100
appName: hsf-application
serviceName: ${spring.application.name}
version: 0.0.1
healthCheckInterval: 30
config:
# serverAddr: https://cse.cn-south-1.myhuaweicloud.com
serverAddr: http://127.0.0.1:30113
# need when running in huaweicloud
# credentials:
# enabled: true
# accessKey: your ak
# secretKey: your sk
# akskCustomCipher: default
# project: cn-east-2

0 comments on commit 36b3b21

Please sign in to comment.