java.lang.illegalagr_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.beanfactoryPostProcessors(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
無法理解為什么環境不會在彈簧環境中的正確時間注入.
我錯過了什么 ?
問候.
總結
以上是生活随笔為你收集整理的java.lang.illegalagr_spring – java.lang.IllegalArgumentException:环境不能为null的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 页面置换算法先进先出java_页面替换算
- 下一篇: python多进程间通信_python多