forked from apache/incubator-seata-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Spring Cloud Alibaba Samples Project (apache#270)
- Loading branch information
1 parent
fc4372f
commit b784223
Showing
43 changed files
with
1,735 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# spring-cloud-alibaba-samples | ||
## 准备环境 | ||
* 启动 Nacos server <br> | ||
[Nacos Server 下载地址](https://github.com/alibaba/nacos/releases) | ||
>下载最新版本Nacos Server, 本地启动Nacos | ||
* 启动Seata Server <br> | ||
[Seata Server 下载地址](https://github.com/seata/seata/releases) | ||
> 下载最新版本Seata Server, 本地启动Seata | ||
## 使用组件介绍 | ||
* Nacos 注册中心 | ||
* Nacos 配置中心 | ||
* Dubbo RPC 服务调用 | ||
* Open Feign REST 服务调用 | ||
* Sentinel 限流熔断 | ||
* Seata 分布式事务解决方案 | ||
## 项目目录介绍 | ||
* sca-common <br> | ||
`项目公用模块(实体类,Dubbo Api等)` | ||
* sca-customer 消费者 | ||
* sca-provider 服务提供者 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>pom</packaging> | ||
<parent> | ||
<groupId>io.seata</groupId> | ||
<artifactId>seata-samples</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>io.seata</groupId> | ||
<artifactId>spring-cloud-alibaba-samples</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<name>spring-cloud-alibaba-samples</name> | ||
<description>Spring Cloud Alibaba + Nacos + Dubbo + OpenFeign + Sentinel + Seata</description> | ||
<modules> | ||
<module>sca-common</module> | ||
<module>sca-customer</module> | ||
<module>sca-provider</module> | ||
</modules> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<spring-cloud.version>Greenwich.SR1</spring-cloud.version> | ||
<spring-cloud-alibaba.version>2.1.0.RELEASE</spring-cloud-alibaba.version> | ||
<lombok.version>1.16.8</lombok.version> | ||
|
||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<sikpTests>true</sikpTests> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<version>2.1.4.RELEASE</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<!--Spring Cloud--> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<!--Spring Cloud Alibaba--> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-alibaba-dependencies</artifactId> | ||
<version>${spring-cloud-alibaba.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
<encoding>UTF-8</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?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"> | ||
<parent> | ||
<groupId>io.seata</groupId> | ||
<artifactId>spring-cloud-alibaba-samples</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>jar</packaging> | ||
|
||
<artifactId>sca-common</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
...d-alibaba-samples/sca-common/src/main/java/io/seata/samples/sca/common/domain/TbUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.seata.samples.sca.common.domain; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
@Data | ||
public class TbUser implements Serializable{ | ||
/** | ||
* | ||
*/ | ||
private Integer id; | ||
|
||
/** | ||
* | ||
*/ | ||
private String name; | ||
|
||
/** | ||
* | ||
*/ | ||
private Integer age; | ||
} |
9 changes: 9 additions & 0 deletions
9
...ples/sca-common/src/main/java/io/seata/samples/sca/common/dubbo/api/DubboEchoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.seata.samples.sca.common.dubbo.api; | ||
|
||
/** | ||
* Created by yu.hb on 2019-10-30 | ||
*/ | ||
public interface DubboEchoService { | ||
|
||
String echo(String name); | ||
} |
12 changes: 12 additions & 0 deletions
12
...a-samples/sca-common/src/main/java/io/seata/samples/sca/common/dubbo/api/UserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.seata.samples.sca.common.dubbo.api; | ||
|
||
import io.seata.samples.sca.common.domain.TbUser; | ||
|
||
/** | ||
* Description: | ||
* author: yu.hb | ||
* Date: 2019-11-01 | ||
*/ | ||
public interface UserService { | ||
void add(TbUser user); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?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"> | ||
<parent> | ||
<groupId>io.seata</groupId> | ||
<artifactId>spring-cloud-alibaba-samples</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>sca-customer</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>io.seata</groupId> | ||
<artifactId>sca-common</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<!-- Nacos Discovery --> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> | ||
</dependency> | ||
|
||
<!-- Nacos Config --> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> | ||
</dependency> | ||
|
||
<!-- Dubbo Spring Cloud --> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-alibaba-dubbo</artifactId> | ||
</dependency> | ||
|
||
<!-- Seata --> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-seata</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-actuator</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-openfeign</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
|
||
<!-- mybatis --> | ||
<dependency> | ||
<groupId>org.mybatis.spring.boot</groupId> | ||
<artifactId>mybatis-spring-boot-starter</artifactId> | ||
<version>2.1.1</version> | ||
</dependency> | ||
<!-- mybatis --> | ||
|
||
<!--mybatis-generator--> | ||
<dependency> | ||
<groupId>org.mybatis.generator</groupId> | ||
<artifactId>mybatis-generator-core</artifactId> | ||
<version>1.3.7</version> | ||
</dependency> | ||
<!--mybatis-generator--> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.34</version> | ||
</dependency> | ||
|
||
|
||
|
||
|
||
</dependencies> | ||
|
||
</project> |
23 changes: 23 additions & 0 deletions
23
...alibaba-samples/sca-customer/src/main/java/io/seata/samples/sca/customer/CustomerApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.seata.samples.sca.customer; | ||
|
||
import org.mybatis.spring.annotation.MapperScan; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
|
||
/** | ||
* Created by yu.hb on 2019-10-30 | ||
*/ | ||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) | ||
@EnableDiscoveryClient | ||
@EnableFeignClients // 扫描 @FeignClient 注解 | ||
@MapperScan("io.seata.samples.sca.customer.mapper") | ||
public class CustomerApp { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(CustomerApp.class, args); | ||
} | ||
|
||
} |
Oops, something went wrong.