zipkin-reporter-java icon indicating copy to clipboard operation
zipkin-reporter-java copied to clipboard

spring-beans 2.5.6 -> 3.0.0.RELEASE; fix @Bean AutoConfiguration mult…

Open victory-wu opened this issue 1 year ago • 2 comments

After Springbean version 3.0, FactoryBeans automatically configured through @ bean encountered a not found bean error

The reason is that no specific generic type was specified。

In order to reduce the impact, I only upgraded to the minimum version number that supports AbstractFactoryBean<T>

The following is a code example。

erro:not fund AsyncReporter Sender 。。。


    @Bean
    public  OkHttpSenderFactoryBean sender() {
        OkHttpSenderFactoryBean okHttpSenderFactoryBean = new OkHttpSenderFactoryBean();
        okHttpSenderFactoryBean.setEndpoint("http://localhost:9412/api/v2/spans");
        return okHttpSenderFactoryBean;
    }

    @Bean
    public  AsyncReporterFactoryBean reporter(Sender sender) throws Exception {
        AsyncReporterFactoryBean asyncReporterFactoryBean = new AsyncReporterFactoryBean();
        asyncReporterFactoryBean.setSender(sender);
        asyncReporterFactoryBean.setCloseTimeout(500);
        return asyncReporterFactoryBean;
    }

    @Bean
    public ZipkinSpanHandlerFactoryBean spanHandler(AsyncReporter reporter) {
        ZipkinSpanHandlerFactoryBean factoryBean = new ZipkinSpanHandlerFactoryBean();
        factoryBean.setSpanReporter(reporter);
        return factoryBean;
    }

victory-wu avatar Apr 19 '23 14:04 victory-wu

hmm I can understand what you are asking about. On the other hand, we do have code that uses later versions of spring with this dependency. Also, this dependency is intentionally old to support 2.5. To update this will make those apps stop working. Can you have another look, perhaps at the brave-example to see if there is another way to accomplish your goal? https://github.com/openzipkin/brave-example/blob/7c3d4ce09ab81066ae909273792f19cee34229ef/webmvc4-boot/src/main/java/brave/example/TracingAutoConfiguration.java

codefromthecrypt avatar Dec 11 '23 01:12 codefromthecrypt

I haven't had time to create tests for this as there is some more urgent work I have to complete. If someone else can, it is appreciated.

codefromthecrypt avatar Dec 15 '23 00:12 codefromthecrypt