Java Code Examples for org.springframework.beans.factory.config.PropertiesFactoryBean#setIgnoreResourceNotFound()
The following examples show how to use
org.springframework.beans.factory.config.PropertiesFactoryBean#setIgnoreResourceNotFound() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoreAppConfig.java From logsniffer with GNU Lesser General Public License v3.0 | 6 votes |
@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; }
Example 2
Source File: SpringUtils.java From onetwo with Apache License 2.0 | 5 votes |
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; }