当前位置: 首页>>代码示例>>Java>>正文


Java PropertyPlaceholderConfigurer.setProperties方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.setProperties方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyPlaceholderConfigurer.setProperties方法的具体用法?Java PropertyPlaceholderConfigurer.setProperties怎么用?Java PropertyPlaceholderConfigurer.setProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的用法示例。


在下文中一共展示了PropertyPlaceholderConfigurer.setProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyEmbeddedConfigurationContext

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void verifyEmbeddedConfigurationContext() {
    final PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    final Properties properties = new Properties();
    properties.setProperty("mongodb.host", "ds061954.mongolab.com");
    properties.setProperty("mongodb.port", "61954");
    properties.setProperty("mongodb.userId", "casuser");
    properties.setProperty("mongodb.userPassword", "Mellon");
    properties.setProperty("cas.service.registry.mongo.db", "jasigcas");
    configurer.setProperties(properties);

    final FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(
            new String[]{"src/main/resources/META-INF/spring/mongo-services-context.xml"}, false);
    ctx.getBeanFactoryPostProcessors().add(configurer);
    ctx.refresh();

    final MongoServiceRegistryDao dao = new MongoServiceRegistryDao();
    dao.setMongoTemplate(ctx.getBean("mongoTemplate", MongoTemplate.class));
    cleanAll(dao);
    assertTrue(dao.load().isEmpty());
    saveAndLoad(dao);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:MongoServiceRegistryDaoTests.java

示例2: getPropertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
/**
 * Gets the property placeholder configurer.
 *
 * @return the property placeholder configurer
 */
@Bean(name = "propertyPlaceholderConfigurer")
public static PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer() {
  logger.debug("Instantiated propertyPlaceholderConfigurer");
  PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
  configurer.setLocation(new ClassPathResource("stats.properties"));
  configurer.setNullValue("NULL");

  Properties properties = new Properties();
  properties.put("psiprobe.tools.mail.to", "NULL");
  properties.put("psiprobe.tools.mail.subjectPrefix", "[PSI Probe]");
  configurer.setProperties(properties);

  configurer.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_OVERRIDE");

  return configurer;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:22,代码来源:ProbeConfig.java

示例3: testResourceInjectionWithResolvableDependencyType

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testResourceInjectionWithResolvableDependencyType() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition abd = new RootBeanDefinition(ExtendedResourceInjectionBean.class);
	abd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", abd);
	RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class);
	tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("testBean4", tbd);

	bf.registerResolvableDependency(BeanFactory.class, bf);
	bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() {
		@Override
		public Object getObject() throws BeansException {
			return new NestedTestBean();
		}
	});

	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("tb", "testBean4");
	ppc.setProperties(props);
	ppc.postProcessBeanFactory(bf);

	ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
	INestedTestBean tb = bean.getTestBean6();
	assertNotNull(tb);

	ExtendedResourceInjectionBean anotherBean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
	assertNotSame(anotherBean, bean);
	assertNotSame(anotherBean.getTestBean6(), tb);

	String[] depBeans = bf.getDependenciesForBean("annotatedBean");
	assertEquals(1, depBeans.length);
	assertEquals("testBean4", depBeans[0]);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:CommonAnnotationBeanPostProcessorTests.java

示例4: testFormatFieldForAnnotationWithPlaceholders

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
@SuppressWarnings("resource")
public void testFormatFieldForAnnotationWithPlaceholders() throws Exception {
	GenericApplicationContext context = new GenericApplicationContext();
	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("dateStyle", "S-");
	props.setProperty("datePattern", "M-d-yy");
	ppc.setProperties(props);
	context.getBeanFactory().registerSingleton("ppc", ppc);
	context.refresh();
	context.getBeanFactory().initializeBean(formattingService, "formattingService");
	formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
	doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:FormattingConversionServiceTests.java

示例5: testFormatFieldForAnnotationWithPlaceholdersAndFactoryBean

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
@SuppressWarnings("resource")
public void testFormatFieldForAnnotationWithPlaceholdersAndFactoryBean() throws Exception {
	GenericApplicationContext context = new GenericApplicationContext();
	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("dateStyle", "S-");
	props.setProperty("datePattern", "M-d-yy");
	ppc.setProperties(props);
	context.registerBeanDefinition("formattingService", new RootBeanDefinition(FormattingConversionServiceFactoryBean.class));
	context.getBeanFactory().registerSingleton("ppc", ppc);
	context.refresh();
	formattingService = context.getBean("formattingService", FormattingConversionService.class);
	doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:FormattingConversionServiceTests.java

示例6: propertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() throws IOException {

    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    Properties props = propertyFactory();

    configurer.setProperties(props);
    configurer.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
    return configurer;
}
 
开发者ID:aol,项目名称:micro-server,代码行数:11,代码来源:PropertyFileConfig.java

示例7: propertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
    
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setIgnoreResourceNotFound(true);
    final Properties properties = new Properties();
    properties.setProperty("cf.resource", ApiControllerTest.CF_RESOURCE);
    properties.setProperty("cf.cli.version", "");
    properties.setProperty("cf.cli.url", "");
    properties.setProperty("platform.version", "0.1");
    properties.setProperty("platform.coreorg", "coreOrg");
    ppc.setProperties(properties);
 
    return ppc;
}
 
开发者ID:trustedanalytics,项目名称:platform-context,代码行数:16,代码来源:TestConfiguration.java

示例8: propertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
    
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setIgnoreResourceNotFound(true);
    final Properties properties = new Properties();
    properties.setProperty("demo.data", ResourceControllerTest.CF_RESOURCE);
    ppc.setProperties(properties);
 
    return ppc;
}
 
开发者ID:trustedanalytics,项目名称:resource-server-template,代码行数:12,代码来源:TestConfiguration.java

示例9: propertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
/**
 * Returns a general properties placeholder configurer based on
 * {@link #logSnifferProperties()}.
 * 
 * @param props
 *            autowired logSnifferProperties bean
 * @return A general properties placeholder configurer.
 * @throws IOException
 */
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Autowired
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer(
		@Qualifier(BEAN_LOGSNIFFER_PROPS) final Properties props) throws IOException {
	final PropertyPlaceholderConfigurer c = new PropertyPlaceholderConfigurer();
	c.setIgnoreResourceNotFound(true);
	c.setIgnoreUnresolvablePlaceholders(true);
	c.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
	c.setProperties(props);
	return c;
}
 
开发者ID:logsniffer,项目名称:logsniffer,代码行数:22,代码来源:CoreAppConfig.java

示例10: propertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
/**
 * Property placeholder configurer.
 *
 * @return the property placeholder configurer
 */
@Bean(name = "properties")
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {

	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	try {

		properties = new Properties();
		properties.load(FileUtils.getFile("/config.properties"));
		String pathConfig = properties.getProperty("pathConfig");

		// If exist another config.properties, choose the outside
		addResource(pathConfig, "configFile", "/config.properties");

		// Add Resources properties
		addResource(pathConfig, "configBankRemittance", "/bankRemittance.properties");
		addResource(pathConfig, "configFirebaseMessaging", "/firebaseMessaging.properties");
		addResource(pathConfig, "configFirebaseWeb", "/firebaseWeb.properties");	
		addResource(pathConfig, "configHibernate", "/hibernate.properties");
		addResource(pathConfig, "configPaypal", "/paypal.properties");
		addResource(pathConfig, "configReCaptcha", "/recaptcha.properties");

		// Change logs, log4j for hibernate and logback for the rest
		changeLog4j(pathConfig, "configLog4j");
		changeLogBack(pathConfig, "configLogBack");

		// Inicialice firebase
		initializeFirebase(pathConfig, "configFirebaseAdmin", "/firebaseAdmin.json");

		ppc.setProperties(properties);
	} catch (Exception e) {
		logger.error("PropertyPlaceholderConfigurer ", e);
	}
	return ppc;
}
 
开发者ID:pablogrela,项目名称:members_cuacfm,代码行数:40,代码来源:ApplicationConfig.java

示例11: propertyPlaceholderConfigurer

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Bean(name = "properties")
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	try {
		ppc.setProperties(ApplicationConfig.getProperties());
	} catch (Exception e) {
		logger.error("PropertyPlaceholderConfigurer ", e);
	}
	return ppc;
}
 
开发者ID:pablogrela,项目名称:members_cuacfm,代码行数:11,代码来源:WebMvcConfig.java

示例12: testFormatFieldForAnnotationWithPlaceholders

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testFormatFieldForAnnotationWithPlaceholders() throws Exception {
	GenericApplicationContext context = new GenericApplicationContext();
	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("dateStyle", "S-");
	props.setProperty("datePattern", "M-d-yy");
	ppc.setProperties(props);
	context.getBeanFactory().registerSingleton("ppc", ppc);
	context.refresh();
	context.getBeanFactory().initializeBean(formattingService, "formattingService");
	formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
	doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:15,代码来源:FormattingConversionServiceTests.java

示例13: testFormatFieldForAnnotationWithPlaceholdersAndFactoryBean

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testFormatFieldForAnnotationWithPlaceholdersAndFactoryBean() throws Exception {
	GenericApplicationContext context = new GenericApplicationContext();
	PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
	Properties props = new Properties();
	props.setProperty("dateStyle", "S-");
	props.setProperty("datePattern", "M-d-yy");
	ppc.setProperties(props);
	context.registerBeanDefinition("formattingService", new RootBeanDefinition(FormattingConversionServiceFactoryBean.class));
	context.getBeanFactory().registerSingleton("ppc", ppc);
	context.refresh();
	formattingService = context.getBean("formattingService", FormattingConversionService.class);
	doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:15,代码来源:FormattingConversionServiceTests.java

示例14: testProperties

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testProperties() throws Exception {
	AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
	ctx.scan(TestSpringInit.class.getPackage().getName());
	PropertyPlaceholderConfigurer config = new PropertyPlaceholderConfigurer();
	config.setProperties(props);
	config.postProcessBeanFactory(ctx.getDefaultListableBeanFactory());
	ctx.refresh();
	
	TestBean b = ctx.getBean(TestBean.class);
	assertEquals("hello", b.getText());
	assertEquals(propsFile.getAbsolutePath(), b.getFilename());
	
	ctx.close();
}
 
开发者ID:th-schwarz,项目名称:pmcms,代码行数:16,代码来源:TestSpringInit.java

示例15: SpringUtils

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public SpringUtils(AbstractResource conf, Properties properties) {
	this.context = new XmlBeanFactory(conf);
	if (properties != null) {
		PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
		cfg.setProperties(properties);
		cfg.postProcessBeanFactory(context);
	}
}
 
开发者ID:NCIP,项目名称:cagrid2,代码行数:9,代码来源:SpringUtils.java


注:本文中的org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.setProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。