java.lang.illegalagr_spring – java.lang.IllegalArgumentException:环境不能为null
我嘗試設(shè)置一個(gè)基本的SolrRepository應(yīng)用程序并在ApplicationContext加載期間出現(xiàn)此錯(cuò)誤:
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());
}
}
和我的存儲(chǔ)庫界面:
package sandBox.solr.repository;
import org.springframework.data.solr.repository.SolrCrudRepository;
public interface SandBoxRepository extends SolrCrudRepository
無法理解為什么環(huán)境不會(huì)在彈簧環(huán)境中的正確時(shí)間注入.
我錯(cuò)過了什么 ?
問候.
總結(jié)
以上是生活随笔為你收集整理的java.lang.illegalagr_spring – java.lang.IllegalArgumentException:环境不能为null的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 页面置换算法先进先出java_页面替换算
- 下一篇: python多进程间通信_python多