本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
}