Java 11493 (#12349)

* moved spring-cloud-bus (submodule) to spring-cloud-modules (parent)

* moved spring-cloud-cli (submodule) to spring-cloud-modules (parent)

* moved spring-cloud-data-flow (submodule) to spring-cloud-modules (parent)

* moved spring-sleuth (submodule) to spring-cloud-modules (parent)

* Deleted submodules that we moved to  spring-cloud-modules

* deleted old modules from parent pom

Co-authored-by: panagiotiskakos <[email protected]>
This commit is contained in:
panos-kakos
2022-06-15 23:30:49 +05:30
committed by GitHub
co-authored by panagiotiskakos
parent cd1a8c8fe4
commit 9be62e0311
90 changed files with 246 additions and 222 deletions
+3
View File
@@ -50,6 +50,9 @@
<module>spring-cloud-sentinel</module>
<module>spring-cloud-dapr</module>
<module>spring-cloud-docker</module>
<module>spring-cloud-bus</module>
<module>spring-cloud-data-flow</module>
<module>spring-sleuth</module>
</modules>
<build>
@@ -0,0 +1,7 @@
## Spring Cloud Bus
This module contains articles about Spring Cloud Bus
### Relevant articles
- [Spring Cloud Bus](https://www.baeldung.com/spring-cloud-bus)
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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</groupId>
<artifactId>spring-cloud-bus</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>spring-cloud-bus</name>
<packaging>pom</packaging>
<parent>
<groupId>com.baeldung.spring.cloud</groupId>
<artifactId>spring-cloud-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modules>
<module>spring-cloud-config-client</module>
<module>spring-cloud-config-server</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<spring-cloud-dependencies.version>2021.0.0</spring-cloud-dependencies.version>
</properties>
</project>
@@ -0,0 +1,55 @@
<?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-config-client</artifactId>
<name>spring-cloud-config-client</name>
<packaging>jar</packaging>
<description>Demo Spring Cloud Config Client</description>
<parent>
<groupId>com.baeldung.spring.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,32 @@
package com.baeldung;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
@RefreshScope
public class SpringCloudConfigClientApplication {
@Value("${user.role}")
private String role;
@Value("${user.password}")
private String password;
public static void main(String[] args) {
SpringApplication.run(SpringCloudConfigClientApplication.class, args);
}
@RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public String whoami(@PathVariable("username") String username) {
return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password);
}
}
@@ -0,0 +1,27 @@
---
spring:
application:
name: config-client
profiles:
active: development
config:
import: configserver:http://root:s3cr3t@localhost:8888
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
cloud:
bus:
enabled: true
refresh:
enabled: true
config:
fail-fast: true
management:
endpoints:
web:
exposure:
include: "*"
security:
enabled: false
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
@@ -0,0 +1,33 @@
package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.SpringCloudConfigClientApplication;
/**
* This LiveTest requires:
* 1- The 'spring-cloud-bus/spring-cloud-config-server' service running, with valid Spring Cloud Config properties, for instance:
* 1.1- `spring.cloud.config.server.git.uri` pointing to a valid URI, which has `user.role` and `user.password` properties configured in a properties file. For example, to achieve this in a dev environment:
* 1.1.1- `cd my/custom/path`
* 1.1.2- `git init .`
* 1.1.3- `echo user.role=Programmer >> application.properties`
* 1.1.4- `echo user.password=d3v3L >> application.properties`
* 1.1.5- `git add .`
* 1.1.6- `git commit -m 'inital commit'`
* 1.1.7- 'spring-cloud-bus/spring-cloud-config-server' with property `spring.cloud.config.server.git.uri=my/custom/path`
*
* Note: This is enough to run the ContextTest successfully, but to get the full functionality shown in the related article, we'll need also a RabbitMQ instance running (e.g. `docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management`)
*
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringCloudConfigClientApplication.class)
public class SpringContextLiveTest {
@Test
public void contextLoads() {
}
}
@@ -0,0 +1,50 @@
<?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-config-server</artifactId>
<name>spring-cloud-config-server</name>
<packaging>jar</packaging>
<description>Demo Spring Cloud Config Server</description>
<parent>
<groupId>com.baeldung.spring.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,14 @@
package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class SpringCloudConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudConfigServerApplication.class, args);
}
}
@@ -0,0 +1,14 @@
server.port=8888
spring.cloud.config.server.git.uri=
spring.cloud.bus.enabled=true
spring.security.user.name=root
spring.security.user.password=s3cr3t
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
encrypt.key-store.location=classpath:/config-server.jks
encrypt.key-store.password=my-s70r3-s3cr3t
encrypt.key-store.alias=config-server-key
encrypt.key-store.secret=my-k34-s3cr3t
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
@@ -0,0 +1,16 @@
package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringCloudConfigServerApplicationIntegrationTest {
@Test
public void contextLoads() {
}
}
@@ -0,0 +1,18 @@
package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.SpringCloudConfigServerApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringCloudConfigServerApplication.class)
public class SpringContextTest {
@Test
public void contextLoads() {
}
}
@@ -0,0 +1,6 @@
## Spring Cloud CLI
This module contains articles about Spring Cloud CLI
### Relevant Articles:
- [Introduction to Spring Cloud CLI](https://www.baeldung.com/spring-cloud-cli)
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
echo Decrypting my_value as key my_key
spring decrypt --key my_key
echo
echo You should see: \"my_value\"
echo
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
echo Encrypting my_value as key my_key
spring encrypt my_value --key my_key
echo
echo You should see something like: c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b
echo
echo You can use: \"{cipher}c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b\" in your configuration files
echo
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo "Run Groovy Rest API Server"
echo "spring run restapi.groovy"
echo "http://localhost:8080/api/get"
spring run restapi.groovy
echo
echo "Run Groovy Eureka Server"
echo "spring run eureka.groovy"
echo "http://localhost:8761"
spring run eureka.groovy
echo
@@ -0,0 +1,2 @@
@EnableEurekaServer
class Eureka {}
@@ -0,0 +1,6 @@
@RestController
@RequestMapping('/api')
class api {
@GetMapping('/get')
def get() { [message: 'Hello'] }
}
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
echo "Install SDKMan"
sudo apt-get update
sudo apt-get install unzip zip -y
sudo curl -s get.sdkman.io | bash
sudo source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version
echo "Install Spring Dependencies"
sudo sdk install groovy
sudo sdk install java
sudo sdk install maven
echo "Install Spring Boot"
sudo sdk install springboot
spring --version
echo "Installing JCE"
sudo apt-get install p7zip-full
echo please go to: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
echo Download the jce_policy-8.zip after you agree to the terms
sleep 25
sudo 7z x jce_policy-8.zip
sudo mv /usr/lib/jvm/java-8-oracle/jre/lib/security/local_policy.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/local_policy.jar.backup
sudo mv /usr/lib/jvm/java-8-oracle/jre/lib/security/US_export_policy.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/US_export_policy.jar.backup
sudo mv UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/
echo
echo "Installing Spring Cloud CLI"
spring install org.springframework.cloud:spring-cloud-cli:1.3.2.RELEASE
echo
echo "Verify Installation"
spring cloud --version
echo
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
echo "Run Config Server"
echo "spring cloud configserver"
echo "http://localhost:8888"
spring cloud configserver
echo
echo "Run Eureka Server"
echo "spring cloud eureka"
echo "http://localhost:8761"
spring cloud eureka
echo
echo "Run H2 Server"
echo "spring cloud h2"
echo "http://localhost:9095"
spring cloud h2
echo
echo "Run Kafka Server"
echo "spring cloud kafka"
echo "http://localhost:9091"
spring cloud kafka
echo
echo "Run Zipkin Server"
echo "spring cloud zipkin"
echo "http://localhost:9411"
spring cloud zipkin
echo
echo "Run Dataflow Server"
echo "spring cloud dataflow"
echo "http://localhost:9393"
spring cloud dataflow
echo
echo "Run Hystrixdashboard Server"
echo "spring cloud hystrixdashboard"
echo "http://localhost:7979"
spring cloud hystrixdashboard
echo
echo "List Services"
echo "spring cloud --list"
spring cloud --list
echo
@@ -0,0 +1,4 @@
spring:
profiles:
active: git
cloud.config.server.git.uri: https://github.com/spring-cloud/spring-cloud-cli/tree/master/spring-cloud-launcher/spring-cloud-launcher-configserver
@@ -0,0 +1,8 @@
spring:
profiles:
active: git
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud/spring-cloud-cli/tree/master/spring-cloud-launcher/spring-cloud-launcher-eureka
@@ -0,0 +1,3 @@
## Spring Cloud Data Flow
This is an aggregator module for Spring Cloud Data Flow modules.
@@ -0,0 +1,3 @@
### Relevant Articles:
- [Spring Cloud Data Flow With Apache Spark](https://www.baeldung.com/spring-cloud-data-flow-spark)
@@ -0,0 +1,34 @@
<?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>apache-spark-job</artifactId>
<name>apache-spark-job</name>
<parent>
<groupId>com.baeldung.spring.cloud</groupId>
<artifactId>spring-cloud-data-flow</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-core</artifactId>
<version>${spring-cloud-task-core.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
</dependencies>
<properties>
<spark.version>1.6.2</spark.version>
<scala.version>2.10</scala.version>
<spring-cloud-task-core.version>2.0.0.RELEASE</spring-cloud-task-core.version>
</properties>
</project>
@@ -0,0 +1,39 @@
package com.baeldung.spring.cloud;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.rdd.RDD;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class PiApproximation {
public static void main(String[] args) {
SparkConf conf = new SparkConf().setAppName("BaeldungPIApproximation").setMaster("local[2]");
JavaSparkContext context = new JavaSparkContext(conf);
int slices = args.length >= 1 ? Integer.valueOf(args[0]) : 2;
int n = (100000L * slices) > Integer.MAX_VALUE ? Integer.MAX_VALUE : 100000 * slices;
List<Integer> xs = IntStream.rangeClosed(0, n)
.mapToObj(element -> Integer.valueOf(element))
.collect(Collectors.toList());
JavaRDD<Integer> dataSet = context.parallelize(xs, slices);
JavaRDD<Integer> pointsInsideTheCircle = dataSet.map(integer -> {
double x = Math.random() * 2 - 1;
double y = Math.random() * 2 - 1;
return (x*x + y*y ) < 1 ? 1: 0;
});
int count = pointsInsideTheCircle.reduce((integer, integer2) -> integer + integer2);
System.out.println("The pi was estimated as:" + count / n);
context.stop();
}
}
@@ -0,0 +1,3 @@
### Relevant Articles:
- [Batch Processing with Spring Cloud Data Flow](http://www.baeldung.com/spring-cloud-data-flow-batch-processing)

Some files were not shown because too many files have changed in this diff Show More