Fix duplicate bean exceptions after spring-boot 3.2 update 04/143104/1 master
authorFiete Ostkamp <fiete.ostkamp@telekom.de>
Tue, 3 Feb 2026 09:50:03 +0000 (10:50 +0100)
committerFiete Ostkamp <fiete.ostkamp@telekom.de>
Tue, 3 Feb 2026 09:50:03 +0000 (10:50 +0100)
- spring-boot 3.2 seems to be stricter as to how beans may be declared
- to avoid DuplicateBeanExceptions, @Component and @Service annotations
  are removed from some classes in favor of solely relying on their
  @Bean declarations in @Configuration classes

Issue-ID: AAI-4223
Change-Id: I4bb53680bc86f4ff34a6c32d9273c69b34f5ba1d
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
aai-core/src/main/java/org/onap/aai/kafka/DeltaProducer.java
aai-core/src/main/java/org/onap/aai/kafka/DeltaProducerService.java
aai-core/src/main/java/org/onap/aai/kafka/NotificationProducer.java
aai-core/src/main/java/org/onap/aai/kafka/NotificationProducerService.java
aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java

index d1b74fd..0ae9d78 100644 (file)
@@ -21,9 +21,7 @@
 package org.onap.aai.kafka;
 
 import org.onap.aai.domain.deltaEvent.DeltaEvent;
-import org.springframework.stereotype.Service;
 
-@Service
 public interface DeltaProducer {
   public void sendNotification(DeltaEvent notificationEvent);
 }
index c84391f..be5632b 100644 (file)
@@ -23,11 +23,9 @@ package org.onap.aai.kafka;
 import org.onap.aai.domain.deltaEvent.DeltaEvent;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.kafka.core.KafkaTemplate;
-import org.springframework.stereotype.Service;
 
 import lombok.RequiredArgsConstructor;
 
-@Service
 @RequiredArgsConstructor
 public class DeltaProducerService implements DeltaProducer {
 
index 3c73917..8eccd3b 100644 (file)
@@ -22,9 +22,7 @@ package org.onap.aai.kafka;
 
 import org.onap.aai.domain.notificationEvent.NotificationEvent;
 import org.onap.aai.rest.notification.UEBNotification;
-import org.springframework.stereotype.Service;
 
-@Service
 public interface NotificationProducer {
   public void sendNotification(NotificationEvent notificationEvent);
   public void sendUEBNotification(UEBNotification uebNotification);
index 44a03ba..ad81ff4 100644 (file)
@@ -24,11 +24,9 @@ import org.onap.aai.domain.notificationEvent.NotificationEvent;
 import org.onap.aai.rest.notification.UEBNotification;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.kafka.core.KafkaTemplate;
-import org.springframework.stereotype.Service;
 
 import lombok.RequiredArgsConstructor;
 
-@Service
 @RequiredArgsConstructor
 public class NotificationProducerService implements NotificationProducer {
 
index 3723a0c..7eef7a4 100644 (file)
@@ -29,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.PropertySource;
 
 @Configuration
@@ -37,8 +38,9 @@ import org.springframework.context.annotation.PropertySource;
 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
 public class ConfigConfiguration {
 
-    @Bean(name = "schemaConfigVersions")
+    @Primary
     @ConditionalOnMissingBean
+    @Bean(name = "schemaConfigVersions")
     public SchemaConfigVersions schemaConfigVersions() {
         return new SchemaConfigVersions();
     }
index 6f899d7..1ef09b3 100644 (file)
@@ -26,14 +26,7 @@ import java.util.stream.Collectors;
 import jakarta.annotation.PostConstruct;
 
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
 
-@Component("schemaConfigVersions")
-@ConditionalOnExpression("'${schema.translator.list:config}'.contains('config') || '${schema.service.versions.override:false}'.equals('true')")
-@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
-@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
 public class SchemaConfigVersions extends SchemaVersions {
 
     @Value("#{'${schema.version.list:''}'.split(',')}")