New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.3.6 retrofit-spring-boot-starter不支持springboot2.7.0以上版本 #123
Comments
再次测试了下 这样设置是正常运行的 |
换成springboot 2.7.2 报错如下: 2022-08-08 16:30:48.159 INFO 9208 --- [ main] c.g.l.r.s.boot.log.LoggingInterceptor : --> GET http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp java.lang.NoSuchMethodError: 'boolean okhttp3.internal.http.HttpHeaders.promisesBody(okhttp3.Response)'
|
看起来还是okhttp版本不对,试试引入完整依赖: <dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.3.6</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.14.9</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.9</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.17.5</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-jackson</artifactId>
<version>2.9.0</version>
</dependency> |
oki依赖冲突导致,2.3.7版本已解决,烦请试试。 |
测试过了, springboot 2.3.7, retrofit-spring-boot-starter 2.3.7 正常运行, 但启动有警告 WARNING: An illegal reflective access operation has occurred |
这个是警告对实际运行无影响。
原因是在Java8以上版本进行了反射调用,并且是在Retrofit底层调用的,现有组件无法处理掉。
发件人: ***@***.***> 代表 blazings ***@***.***>
答复: LianjiaTech/retrofit-spring-boot-starter ***@***.***>
日期: 2022年9月7日 星期三 下午12:28
收件人: LianjiaTech/retrofit-spring-boot-starter ***@***.***>
抄送: chentianming ***@***.***>, State change ***@***.***>
主题: Re: [LianjiaTech/retrofit-spring-boot-starter] 2.3.6 retrofit-spring-boot-starter不支持springboot2.7.0以上版本 (Issue #123)
测试过了, springboot 2.3.7, retrofit-spring-boot-starter 2.3.7 正常运行,
但启动有警告
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by retrofit2.Platform (file:/C:/code/mavenrepo/com/squareup/retrofit2/retrofit/2.9.0/retrofit-2.9.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of retrofit2.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
springboot 2.7 还是报错 2022-11-12 00:35:38.726 WARN 41516 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'retrofitConfigBean' defined in class path resource [com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.class]: Unsatisfied dependency expressed through method 'retrofitConfigBean' parameter 5; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. APPLICATION FAILED TO START Description: Parameter 5 of method retrofitConfigBean in com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration required a bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' that could not be found. Action: Consider defining a bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' in your configuration. |
retrofit-spring-boot-starter 升级到最新版本还报错吗?
这个看起来是LoggingInterceptor没有正常注入,但是这个bean在RetrofitAutoConfiguration是有相关定义的。
根据目前的日志,没法定位到具体原因,麻烦提供完整的日志。
…------------------ 原始邮件 ------------------
发件人: "LianjiaTech/retrofit-spring-boot-starter" ***@***.***>;
发送时间: 2022年11月12日(星期六) 凌晨0:37
***@***.***>;
***@***.***>;"State ***@***.***>;
主题: Re: [LianjiaTech/retrofit-spring-boot-starter] 2.3.6 retrofit-spring-boot-starter不支持springboot2.7.0以上版本 (Issue #123)
springboot 2.7 还是报错
2022-11-12 00:35:38.726 WARN 41516 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'retrofitConfigBean' defined in class path resource [com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.class]: Unsatisfied dependency expressed through method 'retrofitConfigBean' parameter 5; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2022-11-12 00:35:39.047 INFO 41516 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closing ...
2022-11-12 00:35:39.050 INFO 41516 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed
2022-11-12 00:35:39.061 INFO 41516 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-11-12 00:35:39.075 ERROR 41516 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Parameter 5 of method retrofitConfigBean in com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration required a bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' that could not be found.
Action:
Consider defining a bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' in your configuration.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
也可能是你系统里面已经有了同名的loggingInterceptor Bean实例导致的。
你可以试试手动定义一下:
@bean("retrofitLoggingInterceptor")
public LoggingInterceptor loggingInterceptor() {
return new LoggingInterceptor(retrofitProperties.getGlobalLog());
}
…------------------ 原始邮件 ------------------
发件人: "LianjiaTech/retrofit-spring-boot-starter" ***@***.***>;
发送时间: 2022年11月12日(星期六) 凌晨0:37
***@***.***>;
***@***.***>;"State ***@***.***>;
主题: Re: [LianjiaTech/retrofit-spring-boot-starter] 2.3.6 retrofit-spring-boot-starter不支持springboot2.7.0以上版本 (Issue #123)
springboot 2.7 还是报错
2022-11-12 00:35:38.726 WARN 41516 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'retrofitConfigBean' defined in class path resource [com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.class]: Unsatisfied dependency expressed through method 'retrofitConfigBean' parameter 5; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2022-11-12 00:35:39.047 INFO 41516 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closing ...
2022-11-12 00:35:39.050 INFO 41516 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed
2022-11-12 00:35:39.061 INFO 41516 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-11-12 00:35:39.075 ERROR 41516 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Parameter 5 of method retrofitConfigBean in com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration required a bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' that could not be found.
Action:
Consider defining a bean of type 'com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor' in your configuration.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
2022-08-07 22:18:39.069 WARN 29032 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sourceOkHttpClientRegistry' defined in class path resource [com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.lianjiatech.retrofit.spring.boot.core.SourceOkHttpClientRegistry]: Factory method 'sourceOkHttpClientRegistry' threw exception; nested exception is java.lang.NoSuchFieldError: Companion
2022-08-07 22:18:39.078 INFO 29032 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-08-07 22:18:39.123 ERROR 29032 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sourceOkHttpClientRegistry' defined in class path resource [com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.lianjiatech.retrofit.spring.boot.core.SourceOkHttpClientRegistry]: Factory method 'sourceOkHttpClientRegistry' threw exception; nested exception is java.lang.NoSuchFieldError: Companion
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.20.jar:5.3.20]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.20.jar:5.3.20]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0]
at com.blazings.suanfa.SuanfaApplication.main(SuanfaApplication.java:16) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.0.jar:2.7.0]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.lianjiatech.retrofit.spring.boot.core.SourceOkHttpClientRegistry]: Factory method 'sourceOkHttpClientRegistry' threw exception; nested exception is java.lang.NoSuchFieldError: Companion
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.20.jar:5.3.20]
... 23 common frames omitted
Caused by: java.lang.NoSuchFieldError: Companion
at okhttp3.internal.Util.(Util.kt:70) ~[okhttp-4.9.3.jar:na]
at okhttp3.OkHttpClient.(OkHttpClient.kt:1073) ~[okhttp-4.9.3.jar:na]
at com.github.lianjiatech.retrofit.spring.boot.core.SourceOkHttpClientRegistry.(SourceOkHttpClientRegistry.java:27) ~[retrofit-spring-boot-starter-2.3.6.jar:na]
at com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration.sourceOkHttpClientRegistry(RetrofitAutoConfiguration.java:73) ~[retrofit-spring-boot-starter-2.3.6.jar:na]
at com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration$$EnhancerBySpringCGLIB$$e630bed7.CGLIB$sourceOkHttpClientRegistry$4() ~[retrofit-spring-boot-starter-2.3.6.jar:na]
at com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration$$EnhancerBySpringCGLIB$$e630bed7$$FastClassBySpringCGLIB$$93a0271d.invoke() ~[retrofit-spring-boot-starter-2.3.6.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.20.jar:5.3.20]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.20.jar:5.3.20]
at com.github.lianjiatech.retrofit.spring.boot.config.RetrofitAutoConfiguration$$EnhancerBySpringCGLIB$$e630bed7.sourceOkHttpClientRegistry() ~[retrofit-spring-boot-starter-2.3.6.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.20.jar:5.3.20]
... 24 common frames omitted
与目标 VM 断开连接, 地址为: ''127.0.0.1:59215',传输: '套接字''
进程已结束,退出代码0
The text was updated successfully, but these errors were encountered: