Java 弹簧注入误差

Java 弹簧注入误差,java,spring,mybatis,spring-mybatis,Java,Spring,Mybatis,Spring Mybatis,弹簧配置: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring" xsi:schemaLo

弹簧配置:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">


<mybatis-spring:scan base-package="com.example.dao.**" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/schema15" />
    <property name="username" value="root" />
    <property name="password" value="password" />
</bean>
<bean id="sqlSessionFactoryBean"
    class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="configLocation"
        value="classpath:mybatis-config.xml">
    </property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/web-services
   http://www.springframework.org/schema/web-services/web-services-2.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">


  <context:component-scan
     base-package="com.example.services,com.example.userlogin.schemas," />
   <sws:annotation-driven />

  <!-- Our test service bean -->
  <bean id="UserService"
  class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"
  lazy-init="true">
  <property name="schemaCollection">
   <bean
   class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
      <property name="inline" value="true" />
      <property name="xsds">
        <list>
          <value>schemas/UserServiceOperations.xsd</value>
        </list>
       </property>
   </bean>
  </property>
  <property name="portTypeName" value="UserService" />
  <property name="serviceName" value="UserService" />
  <property name="locationUri" value="/endpoints" />
  </bean>
  </beans>

任何意见都是非常感谢的!谢谢大家!

不确定mybatis spring扫描是否支持通配符。您是否已尝试显式定义映射器

<bean id="userLoginDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="...myMapperInterface" />
    <property name="sqlSessionFactory" ref="sqlSessionFactoryBean" />
</bean>

“找不到[com.example.dao.IUserLoginDAO]类型的符合依赖项条件的bean:至少需要1个符合此依赖项autowire候选项条件的bean。”您错过了
IUserLoginDAO
bean。如果它用@Component注释,请检查它是否在扫描组件的包中。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceEndpoints': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.services.UserService com.example.services.endpoints.UserServiceEndpoints.userService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.dao.IUserLoginDAO com.example.services.UserServiceImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.example.dao.IUserLoginDAO] 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)}
<bean id="userLoginDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="...myMapperInterface" />
    <property name="sqlSessionFactory" ref="sqlSessionFactoryBean" />
</bean>