Search code examples
spring-dataspring-boot

Autowiring issues with a class in Spring data Mongo repository


For a variety of reasons, I ended up using spring boot 1.2.0 RC2. So a spring data mongo application that worked fine in spring boot1.1.8 is now having issues. No code was changed except for the bump to spring boot 1.2.0 RC2. This is due to the snapshot version of spring cloud moving to this spring boot version.

The repository class is as follows

@Repository
public interface OAuth2AccessTokenRepository extends MongoRepository<OAuth2AuthenticationAccessToken, String> {

    public OAuth2AuthenticationAccessToken findByTokenId(String tokenId);

    public OAuth2AuthenticationAccessToken findByRefreshToken(String refreshToken);

    public OAuth2AuthenticationAccessToken findByAuthenticationId(String authenticationId);

    public List<OAuth2AuthenticationAccessToken> findByClientIdAndUserName(String clientId, String userName);

    public List<OAuth2AuthenticationAccessToken> findByClientId(String clientId);
}

This worked quite well before the bump in versions and now I see this in the log.

19:04:35.510 [main] DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - Ignored because not a concrete top-level class: file [/Users/larrymitchell/rpilprojects/corerpilservicescomponents/channelMap/target/classes/com/cisco/services/rpil/mongo/repository/oauth2/OAuth2AccessTokenRepository.class]

I do have another mongo repository that is recognized but it was defined as a class implementation

@Component 
public class ChannelMapRepository { ... }

This one is recognized (I defined it as a implementation class as a workaround for another problem I had). This class is recognized and seems to work fine.

19:04:35.513 [main] DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - Identified candidate component class: file [/Users/larrymitchell/rpilprojects/corerpilservicescomponents/channelMap/target/classes/com/cisco/services/rpil/services/Microservice.class]

Anyone have an idea why? I looked up the various reasons for why component scanning would not work and nothing lends itself to my issue.


Solution

  • Try removing the @Repository annotation? Worked for me. This was an issue in Github as well.