BAEL-5049 spring-cloud-dapr (#11063)
* BAEL-5049 Added tutorial code for article. * BAEL-5049 Added readme. * Initial code for 2-javasdk to properly include as part of Spring Boot project. * Added binding with rabbitmq. * Removed 1-intro module. * Updates from comments. * Added .gitignore back in. * Cleaned up POMs. * Get rid of .gitignore. * Change controller to use GetMapping. Co-authored-by: Gerald Boersma <gerald.boersma@icsynergy.com>
This commit is contained in:
parent
b623297829
commit
d43ac8d1b5
@ -0,0 +1,5 @@
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: daprConfig
|
||||
spec: {}
|
@ -0,0 +1,9 @@
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: daprConfig
|
||||
spec:
|
||||
nameResolution:
|
||||
component: "consul"
|
||||
configuration:
|
||||
selfRegister: true
|
@ -0,0 +1,13 @@
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: daprConfig
|
||||
spec:
|
||||
nameResolution:
|
||||
component: "consul"
|
||||
configuration:
|
||||
selfRegister: true
|
||||
tracing:
|
||||
samplingRate: "1"
|
||||
zipkin:
|
||||
endpointAddress: "http://localhost:9411/api/v2/spans"
|
44
spring-cloud/spring-cloud-dapr/gateway/pom.xml
Normal file
44
spring-cloud/spring-cloud-dapr/gateway/pom.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?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>
|
||||
<groupId>com.baeldung.spring.cloud.spring-cloud-dapr</groupId>
|
||||
<artifactId>gateway</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>2020.0.3</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
11
spring-cloud/spring-cloud-dapr/gateway/src/main/java/org/example/gateway/GatewayApp.java
Normal file
11
spring-cloud/spring-cloud-dapr/gateway/src/main/java/org/example/gateway/GatewayApp.java
Normal file
@ -0,0 +1,11 @@
|
||||
package org.example.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class GatewayApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayApp.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 3000
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: greeting-service
|
||||
uri: http://localhost:3001/
|
||||
predicates:
|
||||
- Path=/**
|
||||
filters:
|
||||
- RewritePath=/?(?<segment>.*), /$\{segment}
|
||||
|
@ -0,0 +1,13 @@
|
||||
server:
|
||||
port: 3000
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: greeting-service
|
||||
uri: http://localhost:4000/
|
||||
predicates:
|
||||
- Path=/**
|
||||
filters:
|
||||
- RewritePath=//?(?<segment>.*), /v1.0/invoke/greeting/method/$\{segment}
|
33
spring-cloud/spring-cloud-dapr/greeting/pom.xml
Normal file
33
spring-cloud/spring-cloud-dapr/greeting/pom.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?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>
|
||||
<groupId>com.baeldung.spring.cloud.spring-cloud-dapr</groupId>
|
||||
<artifactId>greeting</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
11
spring-cloud/spring-cloud-dapr/greeting/src/main/java/org/example/hello/GreetingApp.java
Normal file
11
spring-cloud/spring-cloud-dapr/greeting/src/main/java/org/example/hello/GreetingApp.java
Normal file
@ -0,0 +1,11 @@
|
||||
package org.example.hello;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class GreetingApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GreetingApp.class, args);
|
||||
}
|
||||
}
|
22
spring-cloud/spring-cloud-dapr/greeting/src/main/java/org/example/hello/GreetingController.java
Normal file
22
spring-cloud/spring-cloud-dapr/greeting/src/main/java/org/example/hello/GreetingController.java
Normal file
@ -0,0 +1,22 @@
|
||||
package org.example.hello;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class GreetingController {
|
||||
@GetMapping(value = "/")
|
||||
public String getGreeting() {
|
||||
return "Welcome to the greeting service.";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/hello")
|
||||
public String getHello() {
|
||||
return "Hello world!";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/goodbye")
|
||||
public String getGoodbye() {
|
||||
return "Goodbye, cruel world!";
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
server:
|
||||
port: 3001
|
19
spring-cloud/spring-cloud-dapr/pom.xml
Normal file
19
spring-cloud/spring-cloud-dapr/pom.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?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>spring-cloud-dapr</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>gateway</module>
|
||||
<module>greeting</module>
|
||||
</modules>
|
||||
</project>
|
Loading…
x
Reference in New Issue
Block a user