org.springframework.beans.factory.config.PropertiesFactoryBean#setIgnoreResourceNotFound ( )源码实例Demo

下面列出了org.springframework.beans.factory.config.PropertiesFactoryBean#setIgnoreResourceNotFound ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: logsniffer   文件: CoreAppConfig.java
@Bean(name = { BEAN_LOGSNIFFER_PROPS })
@Autowired
public PropertiesFactoryBean logSnifferProperties(final ApplicationContext ctx) throws IOException {
	if (ctx.getEnvironment().acceptsProfiles("!" + ContextProvider.PROFILE_NONE_QA)) {
		final File qaFile = File.createTempFile("logsniffer", "qa");
		qaFile.delete();
		final String qaHomeDir = qaFile.getPath();
		logger.info("QA mode active, setting random home directory: {}", qaHomeDir);
		System.setProperty("logsniffer.home", qaHomeDir);
	}
	final PathMatchingResourcePatternResolver pathMatcher = new PathMatchingResourcePatternResolver();
	Resource[] classPathProperties = pathMatcher.getResources("classpath*:/config/**/logsniffer-*.properties");
	final Resource[] metainfProperties = pathMatcher
			.getResources("classpath*:/META-INF/**/logsniffer-*.properties");
	final PropertiesFactoryBean p = new PropertiesFactoryBean();
	for (final Resource r : metainfProperties) {
		classPathProperties = (Resource[]) ArrayUtils.add(classPathProperties, r);
	}
	classPathProperties = (Resource[]) ArrayUtils.add(classPathProperties,
			new FileSystemResource(System.getProperty("logsniffer.home") + "/" + LOGSNIFFER_PROPERTIES_FILE));
	p.setLocations(classPathProperties);
	p.setProperties(System.getProperties());
	p.setLocalOverride(true);
	p.setIgnoreResourceNotFound(true);
	return p;
}
 
源代码2 项目: onetwo   文件: SpringUtils.java
public static PropertiesFactoryBean createPropertiesBySptring(JFishProperties properties, String...classpaths) {
//		PropertiesFactoryBean pfb = new PropertiesFactoryBean();
		PropertiesFactoryBean pfb = new JFishPropertiesFactoryBean(properties);
		pfb.setIgnoreResourceNotFound(true);
		org.springframework.core.io.Resource[] resources = new org.springframework.core.io.Resource[classpaths.length];
		int index = 0;
		for(String classpath : classpaths){
			resources[index++] = classpath(classpath);
		}
		pfb.setLocations(resources);
		return pfb;
	}