我在我的环境中运行一个基于Spring Data的应用程序时遇到了问题。我正在运行Debian,但我的同事们要么使用Mac,要么使用Ubuntu。我的环境变量没有任何特殊设置,并且与其他人使用的Java版本完全相同。
从日志中我看到了这个,表明存在循环引用问题导致实例化失败:
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'flyway.CONFIGURATION_PROPERTIES':
Initialization of bean failed;
...
nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'flyway': Requested bean is currently in
creation: Is there an unresolvable circular reference?
因此,问题似乎在于Flyway需要一些依赖项,而它们需要Flyway。
问题是,为什么只有在我的环境中出现这种情况?即使在使用H2内存的测试中,我也看到了这个问题,所以不是我的数据库有问题。
Spring是否可能出现自动装配混淆的情况,并尝试按错误的顺序执行操作,以便在尝试设置它时存储库为空?
Spring是否具有糟糕实现的拓扑排序来对依赖项进行排序?
为什么它会在我的环境上表现不良?
类路径的顺序可能会影响其行为吗?
======================
该应用程序将由于此错误而无法启动:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contentItemRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Repository interface must not be null on initialization!
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:127)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1517)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1127)
============================
ContentItemRepository的签名是:
@Repository
@Transactional
public interface ContentItemRepository extends JpaRepository<ContentItem, String>, JpaSpecificationExecutor<ContentItem> {
============================
这曾经对我有用,我能够通过迭代所有提交、执行mvn clean install并尝试启动服务器来确定中断构建的提交,直到找到导致问题的提交。
不能为null的"contentItemRepository"就是这个:
@Component
+public class UrlAliasRequestConverter implements Mapper<UrlAliasRequest, UrlAlias> {
+
+ /**
+ * The content item contentItemType repository.
+ */
+ @Autowired
+ private ContentItemRepository contentItemRepository;
@Profile
或@Conditional
)吗? - fateddy