TMP
authorKai Moritz <kai@juplo.de>
Fri, 23 Feb 2024 11:35:31 +0000 (12:35 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 23 Feb 2024 15:13:05 +0000 (16:13 +0100)
src/main/java/de/juplo/kafka/chat/backend/ChatBackendApplication.java
src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java
src/main/resources/application.yml
src/test/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java

index d6c69b7..dbd707e 100644 (file)
@@ -9,12 +9,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
 import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration;
 import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
+import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
 import org.springframework.web.reactive.config.CorsRegistry;
 import org.springframework.web.reactive.config.WebFluxConfigurer;
 
 
 @SpringBootApplication(exclude = {
                MongoReactiveDataAutoConfiguration.class,
+               MongoReactiveAutoConfiguration.class,
                MongoReactiveRepositoriesAutoConfiguration.class,
                MongoAutoConfiguration.class })
 public class ChatBackendApplication implements WebFluxConfigurer
index e27b298..a893e9d 100644 (file)
@@ -1,13 +1,10 @@
 package de.juplo.kafka.chat.backend.storage.nostorage;
 
 import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration;
-import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
 
 
 @ConditionalOnProperty(
@@ -24,18 +21,10 @@ public class NoStorageStorageConfiguration
     return new NoStorageStorageStrategy();
   }
 
-  @Configuration
-  @EnableAutoConfiguration(
-      exclude = {
-          MongoReactiveDataAutoConfiguration.class,
-          MongoReactiveRepositoriesAutoConfiguration.class,
-          MongoAutoConfiguration.class })
-  public static class DisableMongoConfiguration
+  @Bean
+  @Lazy(false)
+  public String foo()
   {
-    @Bean
-    public String foo()
-    {
-      return "FOO";
-    }
+    return "FOO";
   }
 }
index 81d7af9..fae8cc9 100644 (file)
 package de.juplo.kafka.chat.backend.storage.mongodb;
 
-import com.mongodb.ClientSessionOptions;
-import com.mongodb.connection.ClusterDescription;
-import com.mongodb.reactivestreams.client.*;
-import de.juplo.kafka.chat.backend.ChatBackendProperties;
-import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
-import org.bson.Document;
-import org.bson.conversions.Bson;
-import org.reactivestreams.Publisher;
-import org.springframework.boot.autoconfigure.AutoConfigureBefore;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
+import org.springframework.context.annotation.Lazy;
 
 
 @Configuration
 public class MongoDbStorageNotActiveConfiguration
 {
   @Bean
-  public MongoClient dummyClient()
+  @Lazy(false)
+  public String foo()
   {
-    return new MongoClient() {
-      @Override
-      public MongoDatabase getDatabase(String s)
-      {
-        return null;
-      }
-
-      @Override
-      public void close()
-      {
-
-      }
-
-      @Override
-      public Publisher<String> listDatabaseNames()
-      {
-        return null;
-      }
-
-      @Override
-      public Publisher<String> listDatabaseNames(ClientSession clientSession)
-      {
-        return null;
-      }
-
-      @Override
-      public ListDatabasesPublisher<Document> listDatabases()
-      {
-        return null;
-      }
-
-      @Override
-      public <TResult> ListDatabasesPublisher<TResult> listDatabases(Class<TResult> aClass)
-      {
-        return null;
-      }
-
-      @Override
-      public ListDatabasesPublisher<Document> listDatabases(ClientSession clientSession)
-      {
-        return null;
-      }
-
-      @Override
-      public <TResult> ListDatabasesPublisher<TResult> listDatabases(ClientSession clientSession, Class<TResult> aClass)
-      {
-        return null;
-      }
-
-      @Override
-      public ChangeStreamPublisher<Document> watch()
-      {
-        return null;
-      }
-
-      @Override
-      public <TResult> ChangeStreamPublisher<TResult> watch(Class<TResult> aClass)
-      {
-        return null;
-      }
-
-      @Override
-      public ChangeStreamPublisher<Document> watch(List<? extends Bson> list)
-      {
-        return null;
-      }
-
-      @Override
-      public <TResult> ChangeStreamPublisher<TResult> watch(List<? extends Bson> list, Class<TResult> aClass)
-      {
-        return null;
-      }
-
-      @Override
-      public ChangeStreamPublisher<Document> watch(ClientSession clientSession)
-      {
-        return null;
-      }
-
-      @Override
-      public <TResult> ChangeStreamPublisher<TResult> watch(ClientSession clientSession, Class<TResult> aClass)
-      {
-        return null;
-      }
-
-      @Override
-      public ChangeStreamPublisher<Document> watch(ClientSession clientSession, List<? extends Bson> list)
-      {
-        return null;
-      }
-
-      @Override
-      public <TResult> ChangeStreamPublisher<TResult> watch(
-          ClientSession clientSession,
-          List<? extends Bson> list,
-          Class<TResult> aClass)
-      {
-        return null;
-      }
-
-      @Override
-      public Publisher<ClientSession> startSession()
-      {
-        return null;
-      }
-
-      @Override
-      public Publisher<ClientSession> startSession(ClientSessionOptions clientSessionOptions)
-      {
-        return null;
-      }
-
-      @Override
-      public ClusterDescription getClusterDescription()
-      {
-        return null;
-      }
-    };
+    return "FOO";
   }
 }