Error instantiating bean of DefaultKafkaConsumerConfiguration

In my micronaut microservice, I am trying to feed a property my.property.name programatically instead of adding it to the application.yml. I have provided my code below and error I am getting. What should I do to fix this?

Code Approach-1:

import io.micronaut.context.annotation.Context;
import io.micronaut.context.annotation.Requires;
import io.micronaut.context.env.ActiveEnvironment;
import io.micronaut.context.env.PropertySource;
import io.micronaut.context.env.PropertySourceLoader;
import io.micronaut.core.io.ResourceLoader;
import io.micronaut.core.util.CollectionUtils;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;

@Singleton
@Requires(beans = MyService.class)
@Context
public class MyPropertySourceLoader implements PropertySourceLoader {

    private final MyService myService;

    @Inject
    public MyPropertySourceLoader(MyService myService) {
        this.myService = myService;
    }

    @Override
    public Optional<PropertySource> load(String resourceName, ResourceLoader resourceLoader) {

        String myPropertyValue = myService.getProperty("id");
        return Optional.of(PropertySource.of("custom-property", Collections.singletonMap("my.property.name", myPropertyValue), -10000));
    }

    @Override
    public Optional<PropertySource> loadEnv(String resourceName, ResourceLoader resourceLoader, ActiveEnvironment activeEnvironment) {

        String myPropertyValue = myService.getProperty("id");
        return Optional.of(PropertySource.of("custom-property", Collections.singletonMap("my.property.name", myPropertyValue), -10000));
    }

    @Override
    public Map<String, Object> read(String name, InputStream input) throws IOException {

        String myPropertyValue =myService.getProperty("id");
        return CollectionUtils.mapOf("my.property.name", myPropertyValue);
    }
}

Code Approach-2:


 import io.micronaut.context.annotation.Context;
 import io.micronaut.context.env.Environment;
 import io.micronaut.context.env.PropertySource;
 import io.micronaut.context.event.ApplicationEventListener;
 import io.micronaut.context.event.StartupEvent;
 import jakarta.inject.Inject;
 import jakarta.inject.Singleton;
 import java.util.HashMap;
 import java.util.Map;

 @Singleton
 @Context
 @Order(Ordered.HIGHEST_PRECEDENCE) // Ensure this listener is invoked early
 public class PropertyAddingListener implements ApplicationEventListener<StartupEvent> {

    @Inject private Environment environment;

    private final MyService myService;

    @Inject
    public PropertyAddingListener(MyService myService) {
        this.myService = myService;
    }

    @Override
    public void onApplicationEvent(StartupEvent event) {
        Map<String, Object> properties = new HashMap<>();
        properties.put("my.property.name", myService.getProperty("id"));

        PropertySource propertySource = PropertySource.of("customSource", properties, -10000);
        environment.addPropertySource(propertySource);
    }
 }

Error same in both approaches:
ERROR 2024-05-10 21:27:34,040 [main] io.micronaut.runtime.Micronaut: Error starting Micronaut server: Error instantiating bean of type [io.micronaut.configuration.kafka.config.DefaultKafkaConsumerConfiguration]

Message: Could not resolve placeholder ${my.propert.name}
Path Taken: new KafkaConsumerProcessor(……..

I have tried different approaches and but I am getting same error. I have tried increasing precedence of feeding the my.property.name by using @Order(Ordered.HIGHEST_PRECEDENCE) etc. but I am facing same error. What how to fix this issue, or is there any alternative approach to achieve this?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật