gpt4 book ai didi

spring - java.lang.IllegalArgumentException : Environment must not be null

转载 作者:行者123 更新时间:2023-12-02 09:51:57 24 4
gpt4 key购买 nike

我尝试设置一个基本的 SolrRepository 应用程序,但在 ApplicationContext 加载期间出现此错误:

Caused by: java.lang.IllegalArgumentException: Environment must not be null!
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.<init>(RepositoryConfigurationSourceSupport.java:50)
at org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(AnnotationRepositoryConfigurationSource.java:74)
at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:74)
at org.springframework.context.annotation.ConfigurationClassParser.processImport(ConfigurationClassParser.java:394)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:204)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:163)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:138)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:284)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:225)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:120)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
... 28 more

这是我的配置类:

@Configuration
@PropertySource("classpath:sandbox.properties")
@ComponentScan("sandbox.solr")
@EnableSolrRepositories(basePackages = { "sandbox.solr.repository" }, multicoreSupport = true)
public class StreamingSolrConf {

@Resource
private Environment env;

@Bean
public SolrServer solrServer() {
return new HttpSolrServer(env.getRequiredProperty("solr.server.url"));
}

@Bean
public SolrTemplate solrTemplate() {
return new SolrTemplate(solrServer());
}
}

还有我的存储库界面:

package sandbox.solr.repository;

import org.springframework.data.solr.repository.SolrCrudRepository;

public interface SandboxRepository extends SolrCrudRepository<Document, String> {
}

无法弄清楚为什么环境没有在 Spring 上下文中的正确时间注入(inject)。我错过了什么 ?问候。

最佳答案

只是为了解决这个问题(请参阅原始问题的评论):

他将 spring-data-solr-1.2.1.RELEASEspring-3.2.8.RELEASE 一起使用。降级到 spring-data-solr-1.1.3-RELEASE 并保留 spring-3.2.8.RELEASE 或升级到 spring-3.2.9.RELEASE 保留 spring-data-solr-1.2.1.RELEASE 将解决该问题。

关于spring - java.lang.IllegalArgumentException : Environment must not be null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24681259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com