Maven+Spring+SpringMVC+Mybatis中的常见错误

1 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userEmailController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wf.emailservice.backend.service.core.IUserEmailService com.wf.emailservice.backend.web.controller.UserEmailController.userEmailService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userEmailService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wf.emailservice.backend.service.core.IVivofsService com.wf.emailservice.backend.service.core.impl.UserEmailService.vivofsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vivofsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.apache.http.impl.client.CloseableHttpClient com.wf.emailservice.backend.service.core.impl.VivofsService.httpClient; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.apache.http.impl.client.CloseableHttpClient] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

错误形式一: No qualifying bean of type [org.apache.http.impl.client.CloseableHttpClient] 无法找到相应的bean

1  No qualifying bean of type [org.apache.http.impl.client.CloseableHttpClient] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
View Code
1 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userEmailController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vivo.emailservice.backend.service.core.IUserEmailService com.vivo.emailservice.backend.web.controller.UserEmailController.userEmailService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userEmailService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vivo.emailservice.backend.service.core.IVivofsService com.vivo.emailservice.backend.service.core.impl.UserEmailService.vivofsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vivofsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.apache.http.impl.client.CloseableHttpClient com.vivo.emailservice.backend.service.core.impl.VivofsService.httpClient; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.apache.http.impl.client.CloseableHttpClient] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

这里主要原因是缺乏HttpClient的配置文件

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4        xsi:schemaLocation="http://www.springframework.org/schema/beans
 5         http://www.springframework.org/schema/beans/spring-beans.xsd">
 6 
 7     <!-- 管理连接池 -->
 8     <bean id="httpClientConnectionManager" class="org.apache.http.impl.conn.PoolingHttpClientConnectionManager"
 9           destroy-method="close">
10         <property name="maxTotal" value="150"/>
11         <!--目标主机的默认最大连接数-->
12         <property name="defaultMaxPerRoute" value="100"/>
13     </bean>
14 
15     <!-- httpClient工厂-->
16     <bean id="httpClientBuilder" class="org.apache.http.impl.client.HttpClientBuilder">
17         <property name="connectionManager" ref="httpClientConnectionManager"/>
18     </bean>
19 
20     <!-- httpClient对象-->
21     <bean id="httpClient" factory-bean="httpClientBuilder" factory-method="build" scope="prototype">
22     </bean>
23 
24     <!-- 请求配置工厂-->
25     <bean id="requestConfigBuilder" class="org.apache.http.client.config.RequestConfig.Builder">
26         <!--http连接建立的超时时间-->
27         <property name="connectTimeout" value="1000"/>
28         <!--从连接池拿取连接的超时时间-->
29         <property name="connectionRequestTimeout" value="10"/>
30         <!--等待响应数据的超时时间-->
31         <property name="socketTimeout" value="1000"/>
32     </bean>
33 
34     <!-- 请求配置的对象 -->
35     <bean id="requestConfig" factory-bean="requestConfigBuilder" factory-method="build">
36     </bean>
37 
38 
39 </beans>

 2. Non-resolvable parent POM: Failure to find:

   可能存在的第一个问题: 就是没有设置maven的版本,setting.xml路径/

   

可能存在第二个问题就是 子pom.xml文件都要设置相应的父pom.xml文件的路径

 

3. 找不到系统配置文件:xxxx.properties

   原因在于:Idea软件右侧的maven的profile没有勾选相应的环境

  

 

转载于:https://www.cnblogs.com/piaxiaohui/p/7755211.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值