社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
问题描述:
在spring boot开发过程中,引入第三方的jar包,第三方第三方包中大概描述:
@Configuration
@ConditionalOnMissingBean(ServiceFactory.class)
@ConditionalOnProperty(prefix = "wwl.openapi", name = {"url", "appId", "appSecret"})
@EnableConfigurationProperties(OpenApiProperties.class)
public class OpenApiAutoConfiguration {
@Bean
@ConditionalOnMissingBean(OkHttpClient.class)
public OkHttpClient openApiOkHttpClient() {
return new OkHttpClient();
}
@Bean
@ConditionalOnMissingBean(ServiceFactory.class)
@DependsOn("openApiOkHttpClient")
public ServiceFactory openApiServiceFactory(DefaultListableBeanFactory beanFactory) {
OpenApiProperties properties = beanFactory.getBean(OpenApiProperties.class);
return ServiceFactory.getFactory(beanFactory.getBean(OkHttpClient.class), properties.getUrl(), properties.getAppId(), properties.getAppSecret());
}
还有一个propertiy的类;
@ConfigurationProperties(prefix = "wwl.openapi")
public class OpenApiProperties {
private String url;
private String appId;
private String appSecret;
}
在使用过程中,发现一直提是找不到类。后来发现配置中心的参数没有引入导致类包的依赖关系出现问题。
具体调试策略:
application.properties 配置文件中
debug=true
然后再eclipse 项目启动的时候添加
-verbose:class
然后启动后,可以打印出详细的类加载项目,就可以查找处理到底是哪个依赖没有成功导致项目启动失败的
[Loaded org.springframework.web.servlet.mvc.condition.ProducesRequestCondition from file:/D:/tools/apache-maven-3.3.9/myRepository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar]
[Loaded org.springframework.web.servlet.mvc.condition.MediaTypeExpression from file:/D:/tools/apache-maven-3.3.9/myRepository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar]
[Loaded org.springframework.web.servlet.mvc.condition.AbstractMediaTypeExpression from file:/D:/tools/apache-maven-3.3.9/myRepository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar]
[Loaded org.springframework.web.servlet.mvc.condition.ProducesRequestCondition$ProduceMediaTypeExpression from file:/D:/tools/apache-maven-3.3.9/myRepository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar]
[Loaded org.springframework.web.servlet.mvc.condition.RequestConditionHolder from file:/D:/tools/apache-maven-3.3.9/myRepository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar]
2018-12-20 19:36:44.823 INFO 30948 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello]}" onto public java.lang.String com.jianlc.controller.HelloController.sayHello()
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!