欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

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

发布时间:2023/12/4 42 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。