spring – java.lang.IllegalArgumentException:环境不能为null

前端之家收集整理的这篇文章主要介绍了spring – java.lang.IllegalArgumentException:环境不能为null前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_1@我尝试设置一个基本的SolrRepository应用程序并在ApplicationContext加载期间出现此错误

@H_404_1@

  1. Caused by: java.lang.IllegalArgumentException: Environment must not be null!
  2. at org.springframework.util.Assert.notNull(Assert.java:112)
  3. at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.beanfactoryPostProcessors(AbstractApplicationContext.java:630)
  4. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
  5. at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:120)
  6. at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
  7. at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
  8. at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
  9. at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
  10. at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
  11. ... 28 more
@H_404_1@这是我的ConfigClass:

@H_404_1@

  1. @Configuration
  2. @PropertySource("classpath:sandBox.properties")
  3. @ComponentScan("sandBox.solr")
  4. @EnableSolrRepositories(basePackages = { "sandBox.solr.repository" },multicoreSupport = true)
  5. public class StreamingSolrConf {
  6. @Resource
  7. private Environment env;
  8. @Bean
  9. public SolrServer solrServer() {
  10. return new HttpSolrServer(env.getrequiredProperty("solr.server.url"));
  11. }
  12. @Bean
  13. public SolrTemplate solrTemplate() {
  14. return new SolrTemplate(solrServer());
  15. }
  16. }
@H_404_1@和我的存储库界面:

@H_404_1@

  1. package sandBox.solr.repository;
  2. import org.springframework.data.solr.repository.SolrCrudRepository;
  3. public interface SandBoxRepository extends SolrCrudRepository
@H_404_1@无法理解为什么环境不会在弹簧环境中的正确时间注入.
我错过了什么 ?
问候.
最佳答案
只是为了解决这个问题(见原始问题的评论):

@H_404_1@他正在使用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相关文章