Spring   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了spring – java.lang.IllegalArgumentException:环境不能为null大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我尝试设置一个基本的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.<>figurationsourceSupport.java:50)
    at org.springframework.data.repository.config.AnnotationRepositoryConfigurationsource.<>figurationsource.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

这是我的ConfigClass:

@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

无法理解为什么环境不会在弹簧环境中的正确时间注入.
我错过了什么 ?
问候.

最佳答案
只是为了解决这个问题(见原始问题的评论):

他正在使用spring-data-solr-1.2.1.RELEASE和spring-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:环境不能为null全部内容,希望文章能够帮你解决spring – java.lang.IllegalArgumentException:环境不能为null所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。