Example usage for org.springframework.beans.factory.config PropertiesFactoryBean setIgnoreResourceNotFound

List of usage examples for org.springframework.beans.factory.config PropertiesFactoryBean setIgnoreResourceNotFound

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config PropertiesFactoryBean setIgnoreResourceNotFound.

Prototype

public void setIgnoreResourceNotFound(boolean ignoreResourceNotFound) 

Source Link

Document

Set if failure to find the property resource should be ignored.

Usage

From source file:info.naiv.lab.java.tool.sqlite.exporter.AppSettings.java

/**
 *
 * @return// w  w w . j a  va 2s.  com
 */
@Bean(name = "externalProperties")
public PropertiesFactoryBean propertiesFactoryBean() {

    Properties p = new Properties();
    setPropertyIfNotBlank(p, "datasource.url", sourceUrl);
    setPropertyIfNotBlank(p, "datasource.schema", sourceSchema);
    setPropertyIfNotBlank(p, "datasource.username", sourceUsername);
    setPropertyIfNotBlank(p, "datasource.password", sourcePassword);
    setPropertyIfNotBlank(p, "jdbc.driver.directory", jdbcDriverDirectory);

    PropertiesFactoryBean bean = new ResolvablePropertiesFactoryBean();
    bean.setIgnoreResourceNotFound(true);
    bean.setLocation(new FileSystemResource(propertyLocation));
    bean.setProperties(p);
    bean.setLocalOverride(true);
    return bean;
}

From source file:com.logsniffer.app.CoreAppConfig.java

@Bean(name = { BEAN_LOGSNIFFER_PROPS })
@Autowired/*  ww w .j  av  a  2s  .com*/
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;
}