将现有代码从 spring boot 2.2.0 升级到 2.2.1 后,我遇到了一个奇怪的问题。
似乎我的 spring 数据 jdbc 存储库不再以某种方式被扫描:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'de.thd.dmpk.establishmentmanagement.IEstablishmentRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
此外,在引导 2.2.1 中也有此信息调试行:
Spring Data JDBC - Could not safely identify store assignment for repository candidate interface de.thd.dmpk.establishmentmanagement.IEstablishmentRepository. If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org.springframework.data.relational.core.mapping.Table.
当我将所有内容切换回引导 2.2.0 时,信息消息以及上述异常都消失了。
有什么提示吗?
编辑
实体
@Getter
@RequiredArgsConstructor(staticName = "of", access = AccessLevel.PUBLIC, onConstructor = @__({@PersistenceConstructor}))
@EqualsAndHashCode
public final class Establishment {
private final @Id
@With
long establishmentId;
@NotNull
@NotEmpty
@Size(max = 255)
private final
String establishmentName;
}
存储库
interface IEstablishmentRepository extends CrudRepository<Establishment, Long>
到目前为止,@Table
如果您不想更改数据库上的表名,则不需要注释。此外@EnableJdbcRepositories
,以这种方式扫描每个文档:
如果没有配置基本包,则使用配置类所在的包。 https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.java-config
那里发生了奇怪的事情:)