-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
449 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tmp/ | ||
|
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 @@ | ||
|
||
# r-nacos dubbo_v3.x 说明 | ||
|
||
本样例基于dubbo v3.2.14版本,需要jdk 17以上版本。 | ||
|
||
|
||
|
||
## 使用方式 | ||
|
||
1. 启动r-nacos | ||
2. 切换到dubbo_v3.x样例目录 | ||
3. 本地打包 `mvn package` (如果有问题可以用 `mvn install` ) | ||
4. 运行service: `java -jar dubbo-demo-service/target/dubbo-demo-service-1.0-SNAPSHOT.jar` | ||
5. 运行api: `java -jar dubbo-demo-api/target/dubbo-demo-api-1.0-SNAPSHOT.jar` | ||
6. 访问api: `curl "http://127.0.0.1:20785/hi?name=r-nacos"` | ||
|
||
```sh | ||
curl "http://127.0.0.1:20785/hi?name=r-nacos" | ||
[dubbo-demo-service] : Hello, r-nacos | ||
``` | ||
|
||
|
||
|
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,2 @@ | ||
target/ | ||
|
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,68 @@ | ||
<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.rnacos.demo</groupId> | ||
<artifactId>dubbo-demo-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>dubbo-demo-api</artifactId> | ||
<name>dubbo-demo-api</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.rnacos.demo</groupId> | ||
<artifactId>dubbo-demo-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-client</artifactId> | ||
</dependency> | ||
<!-- | ||
--> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-log4j2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-nacos-spring-boot-starter</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
sdk-examples/java/dubbo_v3.x/dubbo-demo-api/src/main/java/com/rnacos/demo/App.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,18 @@ | ||
package com.rnacos.demo; | ||
|
||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
@SpringBootApplication | ||
@EnableDubbo | ||
public class App | ||
{ | ||
public static void main(String[] args) { | ||
SpringApplication.run(App.class,args); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...s/java/dubbo_v3.x/dubbo-demo-api/src/main/java/com/rnacos/demo/foo/api/FooController.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,28 @@ | ||
package com.rnacos.demo.foo.api; | ||
|
||
import com.rnacos.demo.foo.DemoService; | ||
|
||
import org.apache.dubbo.config.annotation.DubboReference; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Component | ||
@RestController | ||
public class FooController { | ||
|
||
@DubboReference | ||
private DemoService demoService; | ||
|
||
@GetMapping("/hi") | ||
public String hello(@RequestParam("name")String name){ | ||
if(name==null){ | ||
name = "default"; | ||
} | ||
return demoService.sayHello(name); | ||
} | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
sdk-examples/java/dubbo_v3.x/dubbo-demo-api/src/main/resources/application.yml
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,18 @@ | ||
server: | ||
port: 20785 | ||
spring: | ||
application: | ||
name: dubbo-demo-api | ||
|
||
dubbo: | ||
application: | ||
logger: slf4j | ||
name: ${spring.application.name} | ||
qos-enable: false | ||
check-serializable: false | ||
registry: | ||
address: nacos://${nacos.address:127.0.0.1}:8848?username=nacos&password=nacos | ||
protocol: | ||
port: 20885 | ||
name: dubbo | ||
|
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,2 @@ | ||
target/ | ||
|
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,28 @@ | ||
<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.rnacos.demo</groupId> | ||
<artifactId>dubbo-demo-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>dubbo-demo-common</artifactId> | ||
<name>dubbo-demo-common</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
sdk-examples/java/dubbo_v3.x/dubbo-demo-common/src/main/java/com/rnacos/demo/App.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,13 @@ | ||
package com.rnacos.demo; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...ples/java/dubbo_v3.x/dubbo-demo-common/src/main/java/com/rnacos/demo/foo/DemoService.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,5 @@ | ||
package com.rnacos.demo.foo; | ||
|
||
public interface DemoService { | ||
String sayHello(String name); | ||
} |
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,2 @@ | ||
target/ | ||
|
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,67 @@ | ||
<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.rnacos.demo</groupId> | ||
<artifactId>dubbo-demo-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>dubbo-demo-service</artifactId> | ||
<name>dubbo-demo-service</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.rnacos.demo</groupId> | ||
<artifactId>dubbo-demo-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-client</artifactId> | ||
</dependency> | ||
<!-- | ||
--> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-log4j2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-nacos-spring-boot-starter</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
|
18 changes: 18 additions & 0 deletions
18
sdk-examples/java/dubbo_v3.x/dubbo-demo-service/src/main/java/com/rnacos/demo/App.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,18 @@ | ||
package com.rnacos.demo; | ||
|
||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
@SpringBootApplication | ||
@EnableDubbo | ||
public class App | ||
{ | ||
public static void main(String[] args) { | ||
SpringApplication.run(App.class,args); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
....x/dubbo-demo-service/src/main/java/com/rnacos/demo/foo/service/impl/DemoServiceImpl.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,17 @@ | ||
package com.rnacos.demo.foo.service.impl; | ||
|
||
import com.rnacos.demo.foo.DemoService; | ||
import org.apache.dubbo.config.annotation.DubboService; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
|
||
@DubboService | ||
public class DemoServiceImpl implements DemoService { | ||
@Value("${spring.application.name}") | ||
private String serviceName; | ||
|
||
public String sayHello(String name) { | ||
//return String.format("Hello, %s",name); | ||
return String.format("[%s] : Hello, %s",serviceName,name); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
sdk-examples/java/dubbo_v3.x/dubbo-demo-service/src/main/resources/application.yml
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,17 @@ | ||
server: | ||
port: 20784 | ||
spring: | ||
application: | ||
name: dubbo-demo-service | ||
|
||
dubbo: | ||
application: | ||
logger: slf4j | ||
name: ${spring.application.name} | ||
qos-enable: false | ||
check-serializable: false | ||
registry: | ||
address: nacos://${nacos.address:127.0.0.1}:8848?username=nacos&password=nacos | ||
protocol: | ||
port: 20884 | ||
name: dubbo |
Oops, something went wrong.