Java Code Examples for org.springframework.core.io.support.PropertiesLoaderUtils

The following examples show how to use org.springframework.core.io.support.PropertiesLoaderUtils. These examples are extracted from open source projects. 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 Project: datax-web   Source File: I18nUtil.java    License: MIT License 6 votes vote down vote up
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = JobAdminConfig.getAdminConfig().getI18n();
        i18n = (i18n!=null && i18n.trim().length()>0)?("_"+i18n):i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 2
Source Project: mPaaS   Source File: InitPropConfigFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 配置文件信息获取
 *
 * @return
 */
@Override
public Map<String, Object> defaultConfig() {
    Map<String, Object> rtnMap = new HashMap<>(1);
    try {
        ClassLoader classLoader = this.getClass().getClassLoader();
        Enumeration<URL> urls = (classLoader != null ?
                classLoader.getResources(getPropFilePath()) :
                ClassLoader.getSystemResources(getPropFilePath()));
        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            UrlResource resource = new UrlResource(url);
            Properties properties = PropertiesLoaderUtils.loadProperties(resource);
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                rtnMap.put((String) entry.getKey(), entry.getValue());
            }
        }
    } catch (IOException e) {
        log.error("加载初始配置错误.", e);
    }
    return rtnMap;
}
 
Example 3
Source Project: open-capacity-platform   Source File: I18nUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18nFile = "i18n/message.properties";

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 4
Source Project: mPass   Source File: InitPropConfigFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 配置文件信息获取
 *
 * @return
 */
@Override
public Map<String, Object> defaultConfig() {
    Map<String, Object> rtnMap = new HashMap<>(1);
    try {
        ClassLoader classLoader = this.getClass().getClassLoader();
        Enumeration<URL> urls = (classLoader != null ?
                classLoader.getResources(getPropFilePath()) :
                ClassLoader.getSystemResources(getPropFilePath()));
        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            UrlResource resource = new UrlResource(url);
            Properties properties = PropertiesLoaderUtils.loadProperties(resource);
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                rtnMap.put((String) entry.getKey(), entry.getValue());
            }
        }
    } catch (IOException e) {
        log.error("加载初始配置错误.", e);
    }
    return rtnMap;
}
 
Example 5
Source Project: microservices-platform   Source File: I18nUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n)?("_"+i18n):i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 6
Source Project: zuihou-admin-boot   Source File: I18nUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Properties loadI18nProp() {
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n) ? ("_" + i18n) : i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource, "UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 7
Source Project: datawave   Source File: DefaultHealthInfoContributor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public VersionInfo versionInfo() {
    String buildTime = null;
    GitInfo gitInfo = null;
    try {
        ClassPathResource cpr = new ClassPathResource("/git.properties", getClass());
        Properties gitProps = PropertiesLoaderUtils.loadProperties(cpr);
        CommitInfo ci = new CommitInfo(gitProps.getProperty("git.commit.time"), gitProps.getProperty("git.commit.id.abbrev"));
        gitInfo = new GitInfo(ci, gitProps.getProperty("git.branch"));
        buildTime = gitProps.getProperty("git.build.time");
    } catch (IOException e) {
        // Ignore -- we just won't have git info.
    }
    
    String version = getClass().getPackage().getImplementationVersion();
    BuildInfo buildInfo = new BuildInfo(version, buildTime);
    return new VersionInfo("default", buildInfo, gitInfo);
}
 
Example 8
public static void main(String[] args) throws IOException {
    // application.properties 文件资源 classpath 路径
    String location = "application.properties";
    // 编码化的 Resource 对象(解决乱码问题)
    EncodedResource resource = new EncodedResource(new ClassPathResource(location), "UTF-8");
    // 加载 application.properties 文件,转化为 Properties 对象
    Properties properties = PropertiesLoaderUtils.loadProperties(resource);
    // 创建 Properties 类型的 PropertySource
    PropertiesPropertySource propertySource = new PropertiesPropertySource("map", properties);
    // 转化为 Spring Boot 2 外部化配置源 ConfigurationPropertySource 集合
    Iterable<ConfigurationPropertySource> propertySources = ConfigurationPropertySources.from(propertySource);
    // 创建 Spring Boot 2 Binder 对象(设置 ConversionService ,扩展类型转换能力)
    Binder binder = new Binder(propertySources, null, conversionService());
    // 执行绑定,返回绑定结果
    BindResult<User> bindResult = binder.bind("user", User.class);
    // 获取绑定对象
    User user = bindResult.get();
    // 输出结果
    System.out.println(user);

}
 
Example 9
Source Project: DataLink   Source File: PropertiesUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取properties文件内容
 *
 * @param propertiesPath :绝对路径
 * @return
 */
public static Properties getProperties(String propertiesPath) throws IOException {

    Properties resultProperties = propertiesMap.get(propertiesPath);

    if (resultProperties == null) {
        Resource resource = new PathResource(propertiesPath);
        try {
            resultProperties = PropertiesLoaderUtils.loadProperties(resource);
        } catch (FileNotFoundException e) {
            resultProperties = null;
        }

        if (resultProperties != null)
            propertiesMap.put(propertiesPath, resultProperties);
    }

    return resultProperties;
}
 
Example 10
Source Project: awesome-delay-queue   Source File: Config.java    License: MIT License 6 votes vote down vote up
@Bean
public AwesomeURL awesomeUrl() throws IOException {
    String configPath = storage+".properties";
    Resource resource = new ClassPathResource(configPath);
    Properties props = PropertiesLoaderUtils.loadProperties(resource);
    Set<String> keySet = props.stringPropertyNames();
    String host = props.getProperty("host");
    int port = Integer.parseInt(props.getProperty("port"));
    String username = props.getProperty("username");
    String password = props.getProperty("password");
    Map<String,String> paramMap = new HashMap<>();
    for (String key:keySet){
        paramMap.put(key, (String) props.get(key));
    }
    AwesomeURL awesomeURL = new AwesomeURL(storage,username,password,host,port,null,paramMap);
    return awesomeURL;
}
 
Example 11
Source Project: xmfcn-spring-cloud   Source File: I18nUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n)?("_"+i18n):i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 12
Source Project: zuihou-admin-cloud   Source File: I18nUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Properties loadI18nProp() {
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n) ? ("_" + i18n) : i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource, "UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 13
Source Project: dlock   Source File: DLockGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Load the lease config from properties, and init the lockConfigMap.
 */
@PostConstruct
public void init() {
    try {
        // Using default path if no specified
        confPath = StringUtils.isBlank(confPath) ? DEFAULT_CONF_PATH : confPath;

        // Load lock config from properties
        Properties properties = PropertiesLoaderUtils.loadAllProperties(confPath);

        // Build the lockConfigMap
        for (Entry<Object, Object> propEntry : properties.entrySet()) {
            DLockType lockType = EnumUtils.valueOf(DLockType.class, propEntry.getKey().toString());
            Integer lease = Integer.valueOf(propEntry.getValue().toString());

            if (lockType != null && lease != null) {
                lockConfigMap.put(lockType, lease);
            }
        }

    } catch (Exception e) {
        throw new RuntimeException("Load distributed lock config fail", e);
    }
}
 
Example 14
Source Project: spring4-understanding   Source File: KeyNamingStrategy.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Merges the {@code Properties} configured in the {@code mappings} and
 * {@code mappingLocations} into the final {@code Properties} instance
 * used for {@code ObjectName} resolution.
 * @throws IOException
 */
@Override
public void afterPropertiesSet() throws IOException {
	this.mergedMappings = new Properties();

	CollectionUtils.mergePropertiesIntoMap(this.mappings, this.mergedMappings);

	if (this.mappingLocations != null) {
		for (int i = 0; i < this.mappingLocations.length; i++) {
			Resource location = this.mappingLocations[i];
			if (logger.isInfoEnabled()) {
				logger.info("Loading JMX object name mappings file from " + location);
			}
			PropertiesLoaderUtils.fillProperties(this.mergedMappings, location);
		}
	}
}
 
Example 15
Source Project: adwords-alerting   Source File: AwAlerting.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the application context, adding the properties configuration file depending on the
 * specified path.
 *
 * @param propertiesResource the properties resource
 * @return the resource loaded from the properties file
 * @throws IOException error opening the properties file
 */
private static Properties initApplicationContextAndProperties(Resource propertiesResource)
    throws IOException {
  LOGGER.trace("Innitializing Spring application context.");
  DynamicPropertyPlaceholderConfigurer.setDynamicResource(propertiesResource);
  Properties properties = PropertiesLoaderUtils.loadProperties(propertiesResource);

  // Selecting the XMLs to choose the Spring Beans to load.
  List<String> listOfClassPathXml = new ArrayList<String>();
  listOfClassPathXml.add("classpath:aw-alerting-processor-beans.xml");

  appCtx = new ClassPathXmlApplicationContext(
      listOfClassPathXml.toArray(new String[listOfClassPathXml.size()]));

  return properties;
}
 
Example 16
private Properties loadDhisConf()
    throws IllegalStateException
{
    try ( InputStream in = locationManager.getInputStream( CONF_FILENAME ) )
    {
        Properties conf = PropertiesLoaderUtils.loadProperties( new InputStreamResource( in ) );
        substituteEnvironmentVariables( conf );

        return conf;
    }
    catch ( LocationManagerException | IOException | SecurityException ex )
    {
        log.debug( String.format( "Could not load %s", CONF_FILENAME ), ex );

        throw new IllegalStateException( "Properties could not be loaded", ex );
    }
}
 
Example 17
Source Project: xxl-job   Source File: I18nUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        String i18nFile = MessageFormat.format("i18n/message_{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
Example 18
static Collection<BinderType> parseBinderConfigurations(ClassLoader classLoader,
		Resource resource) throws IOException, ClassNotFoundException {
	Properties properties = PropertiesLoaderUtils.loadProperties(resource);
	Collection<BinderType> parsedBinderConfigurations = new ArrayList<>();
	for (Map.Entry<?, ?> entry : properties.entrySet()) {
		String binderType = (String) entry.getKey();
		String[] binderConfigurationClassNames = StringUtils
				.commaDelimitedListToStringArray((String) entry.getValue());
		Class<?>[] binderConfigurationClasses = new Class[binderConfigurationClassNames.length];
		int i = 0;
		for (String binderConfigurationClassName : binderConfigurationClassNames) {
			binderConfigurationClasses[i++] = ClassUtils
					.forName(binderConfigurationClassName, classLoader);
		}
		parsedBinderConfigurations
				.add(new BinderType(binderType, binderConfigurationClasses));
	}
	return parsedBinderConfigurations;
}
 
Example 19
Source Project: booties   Source File: ExtInfoEndpointConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public InfoEndpoint infoEndpoint() throws Exception {
	LinkedHashMap<String, Object> info = new LinkedHashMap<String, Object>();
	for (String filename : getAllPropertiesFiles()) {
		Resource resource = new ClassPathResource("/" + filename);
		Properties properties = new Properties();
		if (resource.exists()) {
			properties = PropertiesLoaderUtils.loadProperties(resource);
			String name = resource.getFilename();

			info.put(name.replace(PROPERTIES_SUFFIX, PROPERTIES_SUFFIX_REPLACEMENT), Maps.fromProperties(properties));
		} else {
			if (failWhenResourceNotExists()) {
				throw new RuntimeException("Resource : " + filename + " does not exist");
			} else {
				log.info("Resource {} does not exist", filename);
			}
		}
	}
	return new InfoEndpoint(info);
}
 
Example 20
Source Project: syncope   Source File: XMLContentLoader.java    License: Apache License 2.0 6 votes vote down vote up
private void createViews(final String domain, final DataSource dataSource) throws IOException {
    LOG.debug("[{}] Creating views", domain);

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    Properties views = PropertiesLoaderUtils.loadProperties(viewsXML.getResource());
    views.stringPropertyNames().stream().sorted().forEachOrdered(idx -> {
        LOG.debug("[{}] Creating view {}", domain, views.get(idx).toString());
        try {
            jdbcTemplate.execute(views.getProperty(idx).replaceAll("\\n", " "));
        } catch (DataAccessException e) {
            LOG.error("[{}] Could not create view", domain, e);
        }
    });

    LOG.debug("Views created");
}
 
Example 21
Source Project: syncope   Source File: XMLContentLoader.java    License: Apache License 2.0 6 votes vote down vote up
private void createIndexes(final String domain, final DataSource dataSource) throws IOException {
    LOG.debug("[{}] Creating indexes", domain);

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    Properties indexes = PropertiesLoaderUtils.loadProperties(indexesXML.getResource());
    indexes.stringPropertyNames().stream().sorted().forEachOrdered(idx -> {
        LOG.debug("[{}] Creating index {}", domain, indexes.get(idx).toString());
        try {
            jdbcTemplate.execute(indexes.getProperty(idx));
        } catch (DataAccessException e) {
            LOG.error("[{}] Could not create index", domain, e);
        }
    });

    LOG.debug("Indexes created");
}
 
Example 22
Source Project: alf.io   Source File: SmtpMailer.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static JavaMailSender toMailSender(Map<ConfigurationKeys, ConfigurationManager.MaybeConfiguration> conf) {
    JavaMailSenderImpl r = new CustomJavaMailSenderImpl();
    r.setDefaultEncoding("UTF-8");

    r.setHost(conf.get(SMTP_HOST).getRequiredValue());
    r.setPort(Integer.parseInt(conf.get(SMTP_PORT).getRequiredValue()));
    r.setProtocol(conf.get(SMTP_PROTOCOL).getRequiredValue());
    r.setUsername(conf.get(SMTP_USERNAME).getValueOrDefault(null));
    r.setPassword(conf.get(SMTP_PASSWORD).getValueOrDefault(null));

    String properties = conf.get(SMTP_PROPERTIES).getValueOrDefault(null);

    if (properties != null) {
        try {
            Properties prop = PropertiesLoaderUtils.loadProperties(new EncodedResource(new ByteArrayResource(
                    properties.getBytes(StandardCharsets.UTF_8)), "UTF-8"));
            r.setJavaMailProperties(prop);
        } catch (IOException e) {
            log.warn("error while setting the mail sender properties", e);
        }
    }
    return r;
}
 
Example 23
/**
 * Return the current version of the HSQLDB database, as reported by the database properties file.
 */
public static String getHsqlDbVersion(String dbPath) {
    try {
        return PropertiesLoaderUtils
                .loadProperties(new FileSystemResource(Paths.get(dbPath + ".properties")))
                .getProperty("version");
    } catch (Exception e) {
        LOG.warn("Failed to determine HSQLDB database version", e);
        return null;
    }
}
 
Example 24
Source Project: spring-analysis-note   Source File: KeyNamingStrategy.java    License: MIT License 5 votes vote down vote up
/**
 * Merges the {@code Properties} configured in the {@code mappings} and
 * {@code mappingLocations} into the final {@code Properties} instance
 * used for {@code ObjectName} resolution.
 */
@Override
public void afterPropertiesSet() throws IOException {
	this.mergedMappings = new Properties();
	CollectionUtils.mergePropertiesIntoMap(this.mappings, this.mergedMappings);

	if (this.mappingLocations != null) {
		for (Resource location : this.mappingLocations) {
			if (logger.isDebugEnabled()) {
				logger.debug("Loading JMX object name mappings file from " + location);
			}
			PropertiesLoaderUtils.fillProperties(this.mergedMappings, location);
		}
	}
}
 
Example 25
@Nullable
private static CandidateComponentsIndex doLoadIndex(ClassLoader classLoader) {
	if (shouldIgnoreIndex) {
		return null;
	}

	try {
		Enumeration<URL> urls = classLoader.getResources(COMPONENTS_RESOURCE_LOCATION);
		if (!urls.hasMoreElements()) {
			return null;
		}
		List<Properties> result = new ArrayList<>();
		while (urls.hasMoreElements()) {
			URL url = urls.nextElement();
			Properties properties = PropertiesLoaderUtils.loadProperties(new UrlResource(url));
			result.add(properties);
		}
		if (logger.isDebugEnabled()) {
			logger.debug("Loaded " + result.size() + "] index(es)");
		}
		int totalCount = result.stream().mapToInt(Properties::size).sum();
		return (totalCount > 0 ? new CandidateComponentsIndex(result) : null);
	}
	catch (IOException ex) {
		throw new IllegalStateException("Unable to load indexes from location [" +
				COMPONENTS_RESOURCE_LOCATION + "]", ex);
	}
}
 
Example 26
Source Project: spring-analysis-note   Source File: PluggableSchemaResolver.java    License: MIT License 5 votes vote down vote up
/**
 * Load the specified schema mappings lazily.
 */
private Map<String, String> getSchemaMappings() {
	Map<String, String> schemaMappings = this.schemaMappings;
	if (schemaMappings == null) {
		synchronized (this) {
			schemaMappings = this.schemaMappings;
			if (schemaMappings == null) {
				if (logger.isTraceEnabled()) {
					logger.trace("Loading schema mappings from [" + this.schemaMappingsLocation + "]");
				}
				try {
					Properties mappings =
							PropertiesLoaderUtils.loadAllProperties(this.schemaMappingsLocation, this.classLoader);
					if (logger.isTraceEnabled()) {
						logger.trace("Loaded schema mappings: " + mappings);
					}
					schemaMappings = new ConcurrentHashMap<>(mappings.size());
					CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings);
					this.schemaMappings = schemaMappings;
				}
				catch (IOException ex) {
					throw new IllegalStateException(
							"Unable to load schema mappings from location [" + this.schemaMappingsLocation + "]", ex);
				}
			}
		}
	}
	return schemaMappings;
}
 
Example 27
Source Project: open-capacity-platform   Source File: PropertiesUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static String getString(String key) {
	Properties prop = null;
	try {
		Resource resource = new ClassPathResource(file_name);
		EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
		prop = PropertiesLoaderUtils.loadProperties(encodedResource);
	} catch (IOException e) {
		logger.error(e.getMessage(), e);
	}
	if (prop!=null) {
		return prop.getProperty(key);
	}
	return null;
}
 
Example 28
Source Project: Moss   Source File: ManagementEnvironmentCustomizer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void customize(ConfigurableEnvironment env) {
    try {
        Properties props;
        ClassPathResource resource = new ClassPathResource(DEFAULT_PROPERTY);
        props = PropertiesLoaderUtils.loadProperties(resource);
        props.put(SPRINGBOOT_MANAGEMENT_PORT_KEY, getManagementPort(env));
        env.getPropertySources().addLast(new PropertiesPropertySource("managementProperties", props));
    } catch (IOException e) {
        logger.error("Failed to load " + DEFAULT_PROPERTY);
    }
}
 
Example 29
Source Project: Moss   Source File: ManagementEnvironmentCustomizer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void customize(ConfigurableEnvironment env) {
    try {
        Properties props;
        ClassPathResource resource = new ClassPathResource(DEFAULT_PROPERTY);
        props = PropertiesLoaderUtils.loadProperties(resource);
        props.put(SPRINGBOOT_MANAGEMENT_PORT_KEY, getManagementPort(env));
        env.getPropertySources().addLast(new PropertiesPropertySource("managementProperties", props));
    } catch (IOException e) {
        logger.error("Failed to load " + DEFAULT_PROPERTY);
    }
}
 
Example 30
private static Properties loadProperties(URL url) {
    try {
        return PropertiesLoaderUtils.loadProperties(new UrlResource(url));
    } catch (IOException ex) {
        throw new IllegalArgumentException("Unable to load properties " +
                "from location [" + SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION + "]", ex);
    }
}