@@ -92,6 +92,7 @@
|
||||
<module>spring-boot-3-observation</module>
|
||||
<module>spring-boot-3-test-pitfalls</module>
|
||||
<module>spring-boot-3-testcontainers</module>
|
||||
<module>spring-boot-3-2</module>
|
||||
<module>spring-boot-resilience4j</module>
|
||||
<module>spring-boot-properties</module>
|
||||
<module>spring-boot-properties-2</module>
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
<?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-boot-3-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>spring-boot-3-2</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-3</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mock-server</groupId>
|
||||
<artifactId>mockserver-netty</artifactId>
|
||||
<version>${mockserver.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mock-server</groupId>
|
||||
<artifactId>mockserver-client-java</artifactId>
|
||||
<version>${mockserver.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-docker-compose</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>r2dbc-postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-cassandra</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-neo4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-couchbase</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-tracing-bridge-brave</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.zipkin.reporter2</groupId>
|
||||
<artifactId>zipkin-reporter-brave</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.zipkin.reporter2</groupId>
|
||||
<artifactId>zipkin-sender-urlconnection</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
||||
<profile>
|
||||
<id>docker-compose</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.dockercompose.DockerComposeApplication</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>connection-details</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.connectiondetails.ConnectionDetailsApplication</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<!-- This is needed when using Lombok 1.18.16 and above -->
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>${lombok-mapstruct-binding.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<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>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<mapstruct.version>1.5.2.Final</mapstruct.version>
|
||||
<springdoc.version>2.0.0</springdoc.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
|
||||
<mockserver.version>5.14.0</mockserver.version>
|
||||
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.connectiondetails;
|
||||
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
//@ComponentScan(basePackages = "com.baeldung.connectiondetails")
|
||||
public class ConnectionDetailsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConnectionDetailsApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.baeldung.connectiondetails.adapter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class VaultAdapter {
|
||||
private static final Logger logger = LoggerFactory.getLogger(VaultAdapter.class);
|
||||
public static String getSecret(String secretKey) {
|
||||
logger.info("call vault to get the secret of key: " + secretKey);
|
||||
|
||||
//Postgres keys
|
||||
if (secretKey.equalsIgnoreCase("postgres_secret_key")) {
|
||||
return "postgres";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("postgres_user_key")) {
|
||||
return "postgres";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("postgres_jdbc_url")) {
|
||||
return "jdbc:postgresql://localhost:15432/postgresdb";
|
||||
}
|
||||
//RabbitMQ Server Keys
|
||||
if (secretKey.equalsIgnoreCase("rabbitmq_username")) {
|
||||
return "rabbitmquser";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("rabbitmq_password")) {
|
||||
return "rabbitmq";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("rabbitmq_port")) {
|
||||
return "5672";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("rabbitmq_host")) {
|
||||
return "localhost";
|
||||
}
|
||||
//Redis Server Keys
|
||||
if (secretKey.equalsIgnoreCase("redis_username")) {
|
||||
return null;
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("redis_password")) {
|
||||
return "redis";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("redis_port")) {
|
||||
return "6379";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("redis_host")) {
|
||||
return "localhost";
|
||||
}
|
||||
//Mongo DB Keys
|
||||
if (secretKey.equalsIgnoreCase("mongo_connection_string")) {
|
||||
return "mongodb://localhost:27017/demodb";
|
||||
}
|
||||
|
||||
//r2dbc Keys
|
||||
if (secretKey.equalsIgnoreCase("r2dbc_postgres_user")) {
|
||||
return "postgres";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("r2dbc_postgres_secret")) {
|
||||
return "postgres";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("r2dbc_postgres_host")) {
|
||||
return "localhost";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("r2dbc_postgres_port")) {
|
||||
return "15432";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("r2dbc_postgres_database")) {
|
||||
return "postgresdb";
|
||||
}
|
||||
//Elastic Search Keys
|
||||
if (secretKey.equalsIgnoreCase("elastic_user")) {
|
||||
return "elastic";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("elastic_secret")) {
|
||||
return "secret";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("elastic_host")) {
|
||||
return "localhost";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("elastic_port1")) {
|
||||
return "19200";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("elastic_port2")) {
|
||||
return "19300";
|
||||
}
|
||||
//Cassandra keys
|
||||
if (secretKey.equalsIgnoreCase("cassandra_user")) {
|
||||
return "cassandra";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("cassandra_secret")) {
|
||||
return "secret";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("cassandra_host")) {
|
||||
return "localhost";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("cassandra_port")) {
|
||||
return "19042";
|
||||
}
|
||||
//Neo4j Keys
|
||||
if (secretKey.equalsIgnoreCase("neo4j_secret")) {
|
||||
return "neo4j123";
|
||||
}
|
||||
if (secretKey.equalsIgnoreCase("neo4j_uri")) {
|
||||
return "bolt://localhost:17687";
|
||||
}
|
||||
//Kafka Keys
|
||||
if (secretKey.equalsIgnoreCase("kafka_servers")) {
|
||||
return "localhost:19092";
|
||||
}
|
||||
//Couchbase Keys
|
||||
if(secretKey.equalsIgnoreCase("couch_user")) {
|
||||
return "Administrator";
|
||||
}
|
||||
if(secretKey.equalsIgnoreCase("couch_secret")) {
|
||||
return "password";
|
||||
}
|
||||
if(secretKey.equalsIgnoreCase("couch_connection_string")) {
|
||||
return "couchbase://127.0.0.1:8092";
|
||||
}
|
||||
//Zipkin Keys
|
||||
if(secretKey.equalsIgnoreCase("zipkin_span_endpoint")) {
|
||||
return "http://localhost:9411/api/v2/spans";
|
||||
}
|
||||
return "secretVal";
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomCassandraConnectionDetails implements CassandraConnectionDetails {
|
||||
@Override
|
||||
public List<Node> getContactPoints() {
|
||||
Node node = new Node(
|
||||
VaultAdapter.getSecret("cassandra_host"),
|
||||
Integer.parseInt(VaultAdapter.getSecret("cassandra_port"))
|
||||
);
|
||||
return List.of(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return VaultAdapter.getSecret("cassandra_user");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return VaultAdapter.getSecret("cassandra_secret");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalDatacenter() {
|
||||
return "datacenter-1";
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("cassandra")
|
||||
public class CustomCassandraConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public CassandraConnectionDetails getCustomCassandraConnectionDetails() {
|
||||
return new CustomCassandraConnectionDetails();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseConnectionDetails;
|
||||
|
||||
public class CustomCouchBaseConnectionDetails implements CouchbaseConnectionDetails {
|
||||
@Override
|
||||
public String getConnectionString() {
|
||||
return VaultAdapter.getSecret("couch_connection_string");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return VaultAdapter.getSecret("couch_user");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return VaultAdapter.getSecret("couch_secret");
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("couch")
|
||||
|
||||
public class CustomCouchBaseConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
public CouchbaseConnectionDetails getCouchBaseConnectionDetails() {
|
||||
return new CustomCouchBaseConnectionDetails();
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomElasticsearchConnectionDetails implements ElasticsearchConnectionDetails {
|
||||
@Override
|
||||
public List<Node> getNodes() {
|
||||
Node node1 = new Node(
|
||||
VaultAdapter.getSecret("elastic_host"),
|
||||
Integer.parseInt(VaultAdapter.getSecret("elastic_port1")),
|
||||
Node.Protocol.HTTP
|
||||
);
|
||||
return List.of(node1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return VaultAdapter.getSecret("elastic_user");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return VaultAdapter.getSecret("elastic_secret");
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("elastic")
|
||||
public class CustomElasticsearchConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public ElasticsearchConnectionDetails getCustomElasticConnectionDetails() {
|
||||
return new CustomElasticsearchConnectionDetails();
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.kafka.KafkaConnectionDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomKafkaConnectionDetails implements KafkaConnectionDetails {
|
||||
@Override
|
||||
public List<String> getBootstrapServers() {
|
||||
return List.of(VaultAdapter.getSecret("kafka_servers"));
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.kafka.KafkaConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("kafka")
|
||||
public class CustomKafkaConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
public KafkaConnectionDetails getKafkaConnectionDetails() {
|
||||
return new CustomKafkaConnectionDetails();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.neo4j.driver.AuthToken;
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
import org.springframework.boot.autoconfigure.neo4j.Neo4jConnectionDetails;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class CustomNeo4jConnectionDetails implements Neo4jConnectionDetails {
|
||||
@Override
|
||||
public URI getUri() {
|
||||
try {
|
||||
return new URI(VaultAdapter.getSecret("neo4j_uri"));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public AuthToken getAuthToken() {
|
||||
return AuthTokens.basic("neo4j", VaultAdapter.getSecret("neo4j_secret"));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.neo4j.Neo4jConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("neo4j")
|
||||
public class CustomNeo4jConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public Neo4jConnectionDetails getNeo4jConnectionDetails() {
|
||||
return new CustomNeo4jConnectionDetails();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConnectionDetails;
|
||||
|
||||
public class CustomZipkinConnectionDetails implements ZipkinConnectionDetails {
|
||||
@Override
|
||||
public String getSpanEndpoint() {
|
||||
return VaultAdapter.getSecret("zipkin_span_endpoint");
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("zipkin")
|
||||
public class CustomZipkinConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public ZipkinConnectionDetails getZipkinConnectionDetails() {
|
||||
return new CustomZipkinConnectionDetails();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("jdbc")
|
||||
public class JdbcConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public JdbcConnectionDetails getPostgresConnection() {
|
||||
return new PostgresConnectionDetails();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import com.mongodb.ConnectionString;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails;
|
||||
|
||||
public class MongoDBConnectionDetails implements MongoConnectionDetails {
|
||||
@Override
|
||||
public ConnectionString getConnectionString() {
|
||||
return new ConnectionString(VaultAdapter.getSecret("mongo_connection_string"));
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("mongo")
|
||||
public class MongoDBConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public MongoConnectionDetails getMongoConnectionDetails() {
|
||||
return new MongoDBConnectionDetails();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
|
||||
|
||||
public class PostgresConnectionDetails implements JdbcConnectionDetails {
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return VaultAdapter.getSecret("postgres_user_key");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return VaultAdapter.getSecret("postgres_secret_key");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJdbcUrl() {
|
||||
return VaultAdapter.getSecret("postgres_jdbc_url");
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import io.r2dbc.spi.ConnectionFactoryOptions;
|
||||
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
|
||||
|
||||
public class R2dbcPostgresConnectionDetails implements R2dbcConnectionDetails {
|
||||
@Override
|
||||
public ConnectionFactoryOptions getConnectionFactoryOptions() {
|
||||
|
||||
ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
|
||||
.option(ConnectionFactoryOptions.DRIVER, "postgresql")
|
||||
.option(ConnectionFactoryOptions.HOST, VaultAdapter.getSecret("r2dbc_postgres_host"))
|
||||
.option(ConnectionFactoryOptions.PORT, Integer.valueOf(VaultAdapter.getSecret("r2dbc_postgres_port")))
|
||||
.option(ConnectionFactoryOptions.USER, VaultAdapter.getSecret("r2dbc_postgres_user"))
|
||||
.option(ConnectionFactoryOptions.PASSWORD, VaultAdapter.getSecret("r2dbc_postgres_secret"))
|
||||
.option(ConnectionFactoryOptions.DATABASE, VaultAdapter.getSecret("r2dbc_postgres_database"))
|
||||
.build();
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("r2dbc")
|
||||
public class R2dbcPostgresConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public R2dbcConnectionDetails getR2dbcPostgresConnectionDetails() {
|
||||
return new R2dbcPostgresConnectionDetails();
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RabbitMQConnectionDetails implements RabbitConnectionDetails {
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return VaultAdapter.getSecret("rabbitmq_username");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return VaultAdapter.getSecret("rabbitmq_password");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVirtualHost() {
|
||||
return "/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Address> getAddresses() {
|
||||
return List.of(this.getFirstAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address getFirstAddress() {
|
||||
return new Address(VaultAdapter.getSecret("rabbitmq_host"),
|
||||
Integer.parseInt(VaultAdapter.getSecret("rabbitmq_port")));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("rabbitmq")
|
||||
public class RabbitMQConnectionDetailsConfiguration {
|
||||
@Primary
|
||||
@Bean
|
||||
public RabbitConnectionDetails getRabbitmqConnection() {
|
||||
return new RabbitMQConnectionDetails();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import com.baeldung.connectiondetails.adapter.VaultAdapter;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails;
|
||||
|
||||
public class RedisCacheConnectionDetails implements RedisConnectionDetails {
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return VaultAdapter.getSecret("redis_password");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Standalone getStandalone() {
|
||||
return new Standalone() {
|
||||
@Override
|
||||
public String getHost() {
|
||||
return VaultAdapter.getSecret("redis_host");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return Integer.parseInt(VaultAdapter.getSecret("redis_port"));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.connectiondetails.configuration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Profile("redis")
|
||||
public class RedisConnectionDetailsConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public RedisConnectionDetails getRedisCacheConnection() {
|
||||
return new RedisCacheConnectionDetails();
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.connectiondetails.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class ZipkinDemoController {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(ZipkinDemoController.class);
|
||||
|
||||
@GetMapping("/zipkin/test")
|
||||
public @ResponseBody String testMethod() {
|
||||
logger.info("This is a test");
|
||||
return "This is a test";
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.connectiondetails.entity.elastic;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
|
||||
@Document(indexName = "person")
|
||||
public class Person {
|
||||
String name;
|
||||
@Id
|
||||
String ssn;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSsn() {
|
||||
return ssn;
|
||||
}
|
||||
|
||||
public void setSsn(String ssn) {
|
||||
this.ssn = ssn;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.connectiondetails.entity.neo4j;
|
||||
|
||||
import org.springframework.data.neo4j.core.schema.Id;
|
||||
import org.springframework.data.neo4j.core.schema.Node;
|
||||
|
||||
@Node
|
||||
public class Person {
|
||||
@Id
|
||||
String name;
|
||||
String zipcode;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getZipcode() {
|
||||
return zipcode;
|
||||
}
|
||||
|
||||
public void setZipcode(String zipcode) {
|
||||
this.zipcode = zipcode;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
spring.docker.compose.enabled=true
|
||||
spring.docker.compose.file=./connectiondetails/docker/docker-compose-cassandra.yml
|
||||
spring.docker.compose.skip.in-tests=false
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
||||
spring.mustache.check-template-location=false
|
||||
spring.profiles.active=cassandra
|
||||
spring.cassandra.local-datacenter=dc1
|
||||
#spring.cassandra.keyspace-name=spring_cassandra
|
||||
#spring.cassandra.schema-action=CREATE_IF_NOT_EXISTS
|
||||
spring.data.cassandra.request.timeout=20000 # Set your desired timeout in milliseconds
|
||||
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user