Spring data Mongo 存储库中的类自动装配问题

问题描述 投票:0回答:2

由于种种原因,我最终使用了 Spring Boot 1.2.0 RC2。 因此,一个在 spring boot1.1.8 中运行良好的 spring data mongo 应用程序现在出现了问题。 除了升级到 Spring Boot 1.2.0 RC2 之外,没有更改任何代码。 这是由于 Spring Cloud 的快照版本迁移到了此 Spring Boot 版本。

repository类如下

@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);
}

这在版本升级之前效果很好,现在我在日志中看到了这一点。

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]

我确实有另一个可识别的 mongo 存储库,但它被定义为类实现

@Component 
public class ChannelMapRepository { ... }

这个是被认可的(我将其定义为一个实现类,作为我遇到的另一个问题的解决方法)。 这个类被认可并且似乎工作得很好。

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]

有人知道为什么吗? 我查找了组件扫描不起作用的各种原因,但没有任何原因适合我的问题。

spring-data spring-boot
2个回答
0
投票

尝试删除

@Repository
注释? 为我工作。 这也是 Github 中的一个问题。


0
投票
我也发生了同样的错误,但可能是由于不同的原因。在我的例子中,您使用 @Repository 注释了一个扩展“JpaRepository”的接口,并且忘记在主 Application.java 中添加 @EnableJpaRepositories,这显示了错误消息“ClassPathBeanDefinitionScanner”,“message”:“忽略,因为不是具体的顶部 -级别类:TheRepositoryInterface.java”

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.