Spring Annotation驱动的配置-无法解析匹配的构造函数

时间:2019-01-23 13:55:07

标签: java spring-boot spring-data-jpa

我使用的是Spring Boot 1.5.3.RELEASE版本,现在我需要移至2.0.3.RELEASE。该项目在1.5.3.RELEASE中运行良好。当我尝试在tomcat中部署战争时,出现以下错误:

  

org.springframework.beans.factory.BeanCreationException:错误   创建名称为“ userPartnerDao”的bean:无法解析匹配   构造函数(提示:为简单起见,请指定index / type / name参数   参数以避免类型歧义)

我正在使用注释驱动的配置,并且在我的课程中没有cronstractor,并且我没有使用任何构造函数来实例化项目中任何位置的对象。我找到的答案是针对xml配置的。在我的应用程序类中,我在@ComponentScan和@EntityScan中包含软件包。有什么想法吗?

我的课:

package com.test.dao.h2;

import com.test.domain.UserPartner;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface UserPartnerDao extends JpaRepository<UserPartner, Long> {
    @Query("select u from UserPartner u  where u.userAccessToken =?1")
    UserPartner findByToken(String accessToken);

    UserPartner findByGivenId(String givenId);

    @Query("select u.userAccessSecret from UserPartner u  where u.userAccessToken =?1")
    String getUserAccessSecret(String accessToken);

}

我正在尝试使用userPartnerDao的类:

@Component
public class UserAccessTokenDao
{

    @Autowired
    UserPartnerDao userPartnerDao;


    public void doingStuffMethod(String token, String secret, String userId, String userName)
    {
        // doing stuff

    }

}

0 个答案:

没有答案
相关问题