forked from eacdy/spring-boot-study
-
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.
- Loading branch information
Showing
11 changed files
with
314 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
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,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>spring-boot-dubbo-nacos</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>consumer-sample</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-registry-nacos</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-client</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>sample-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
...-boot-dubbo-nacos/consumer-sample/src/main/java/com/itmuch/dubbo/ConsumerApplication.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,26 @@ | ||
package com.itmuch.dubbo; | ||
|
||
import org.apache.dubbo.config.annotation.Reference; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@EnableAutoConfiguration | ||
public class ConsumerApplication { | ||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Reference(version = "${demo.service.version}") | ||
private DemoService demoService; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ConsumerApplication.class).close(); | ||
} | ||
|
||
@Bean | ||
public ApplicationRunner runner() { | ||
return args -> logger.info(demoService.sayHello("test")); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
spring-boot-dubbo-nacos/consumer-sample/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,12 @@ | ||
spring: | ||
application: | ||
name: consumer-sample | ||
dubbo: | ||
registry: | ||
address: nacos:https://${nacos.host}:${nacos.port} | ||
nacos: | ||
host: 127.0.0.1 | ||
port: 8848 | ||
demo: | ||
service: | ||
version: 1.0.0 |
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,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>spring-boot-dubbo-nacos</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<java.source.version>1.8</java.source.version> | ||
<java.target.version>1.8</java.target.version> | ||
<spring-boot.version>2.1.1.RELEASE</spring-boot.version> | ||
<dubbo.version>2.7.1</dubbo.version> | ||
<nacos.version>1.0.0</nacos.version> | ||
</properties> | ||
|
||
<modules> | ||
<module>sample-api</module> | ||
<module>provider-sample</module> | ||
<module>consumer-sample</module> | ||
</modules> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>sample-api</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<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.apache.dubbo</groupId> | ||
<artifactId>dubbo-dependencies-bom</artifactId> | ||
<version>${dubbo.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
<version>${dubbo.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>${dubbo.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-registry-nacos</artifactId> | ||
<version>${dubbo.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-client</artifactId> | ||
<version>${nacos.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
</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,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>spring-boot-dubbo-nacos</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>provider-sample</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-registry-nacos</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.nacos</groupId> | ||
<artifactId>nacos-client</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>sample-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>8</source> | ||
<target>8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
...-boot-dubbo-nacos/provider-sample/src/main/java/com/itmuch/dubbo/ProviderApplication.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 com.itmuch.dubbo; | ||
|
||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
|
||
@EnableAutoConfiguration | ||
public class ProviderApplication { | ||
public static void main(String[] args) { | ||
new SpringApplicationBuilder(ProviderApplication.class) | ||
.run(args); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...t-dubbo-nacos/provider-sample/src/main/java/com/itmuch/dubbo/service/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.itmuch.dubbo.service; | ||
|
||
import com.itmuch.dubbo.DemoService; | ||
import org.apache.dubbo.config.annotation.Service; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
@Service(version = "${demo.service.version}") | ||
public class DemoServiceImpl implements DemoService { | ||
|
||
@Value("${dubbo.application.name}") | ||
private String serviceName; | ||
|
||
@Override | ||
public String sayHello(String name) { | ||
return String.format("[%s] : Hello, %s", serviceName, name); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
spring-boot-dubbo-nacos/provider-sample/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 @@ | ||
spring: | ||
application: | ||
name: provider-sample | ||
dubbo: | ||
scan: | ||
base-packages: com.itmuch.dubbo.service | ||
protocol: | ||
name: dubbo | ||
port: -1 | ||
registry: | ||
address: nacos:https://${nacos.host}:${nacos.port} | ||
demo: | ||
service: | ||
version: 1.0.0 | ||
nacos: | ||
host: 127.0.0.1 | ||
port: 8848 |
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http:https://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.itmuch.dubbo</groupId> | ||
<artifactId>sample-api</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</project> |
7 changes: 7 additions & 0 deletions
7
spring-boot-dubbo-nacos/sample-api/src/main/java/com/itmuch/dubbo/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,7 @@ | ||
package com.itmuch.dubbo; | ||
|
||
public interface DemoService { | ||
|
||
String sayHello(String name); | ||
|
||
} |