From: Kai Moritz Date: Fri, 23 Feb 2024 11:35:31 +0000 (+0100) Subject: TMP X-Git-Tag: rebase--2024-02-23--16-28~11 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=23deca880c729f2c3bd2595639f3a61c643781ee;p=demos%2Fkafka%2Fchat TMP --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/ChatBackendApplication.java b/src/main/java/de/juplo/kafka/chat/backend/ChatBackendApplication.java index d6c69b75..dbd707e4 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/ChatBackendApplication.java +++ b/src/main/java/de/juplo/kafka/chat/backend/ChatBackendApplication.java @@ -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 diff --git a/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java index e27b298b..a893e9d7 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java @@ -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"; } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 98b2266e..e69de29b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1 +0,0 @@ -debug: true diff --git a/src/test/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java b/src/test/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java index 81d7af9a..fae8cc96 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java +++ b/src/test/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java @@ -1,146 +1,17 @@ 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 listDatabaseNames() - { - return null; - } - - @Override - public Publisher listDatabaseNames(ClientSession clientSession) - { - return null; - } - - @Override - public ListDatabasesPublisher listDatabases() - { - return null; - } - - @Override - public ListDatabasesPublisher listDatabases(Class aClass) - { - return null; - } - - @Override - public ListDatabasesPublisher listDatabases(ClientSession clientSession) - { - return null; - } - - @Override - public ListDatabasesPublisher listDatabases(ClientSession clientSession, Class aClass) - { - return null; - } - - @Override - public ChangeStreamPublisher watch() - { - return null; - } - - @Override - public ChangeStreamPublisher watch(Class aClass) - { - return null; - } - - @Override - public ChangeStreamPublisher watch(List list) - { - return null; - } - - @Override - public ChangeStreamPublisher watch(List list, Class aClass) - { - return null; - } - - @Override - public ChangeStreamPublisher watch(ClientSession clientSession) - { - return null; - } - - @Override - public ChangeStreamPublisher watch(ClientSession clientSession, Class aClass) - { - return null; - } - - @Override - public ChangeStreamPublisher watch(ClientSession clientSession, List list) - { - return null; - } - - @Override - public ChangeStreamPublisher watch( - ClientSession clientSession, - List list, - Class aClass) - { - return null; - } - - @Override - public Publisher startSession() - { - return null; - } - - @Override - public Publisher startSession(ClientSessionOptions clientSessionOptions) - { - return null; - } - - @Override - public ClusterDescription getClusterDescription() - { - return null; - } - }; + return "FOO"; } }