Java Code Examples for org.springframework.beans.factory.config.PropertiesFactoryBean#setLocation()
The following examples show how to use
org.springframework.beans.factory.config.PropertiesFactoryBean#setLocation() .
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: SchedulerConfig.java From Almost-Famous with MIT License | 7 votes |
@Bean public SchedulerFactoryBean schedulerFactoryBean() throws IOException { //获取配置属性 PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); //在quartz.properties中的属性被读取并注入后再初始化对象 propertiesFactoryBean.afterPropertiesSet(); //创建SchedulerFactoryBean SchedulerFactoryBean factory = new SchedulerFactoryBean(); factory.setQuartzProperties(propertiesFactoryBean.getObject()); //使用数据源,自定义数据源 factory.setJobFactory(jobFactory); factory.setWaitForJobsToCompleteOnShutdown(true);//这样当spring关闭时,会等待所有已经启动的quartz job结束后spring才能完全shutdown。 factory.setOverwriteExistingJobs(false); factory.setStartupDelay(1); return factory; }
Example 2
Source File: QuartzConfiguration.java From seppb with MIT License | 6 votes |
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); Properties result = propertiesFactoryBean.getObject(); // 从环境信息中剥离出配置好的环境信息,覆盖默认的配置 String dsName = result.getProperty("org.quartz.jobStore.dataSource"); if (StringUtils.isEmpty(dsName)) { throw new RuntimeException("quartz配置文件错误,org.quartz.jobStore.dataSource不能为空!"); } result.setProperty("org.quartz.dataSource." + dsName + ".URL", jdbcUrl); result.setProperty("org.quartz.dataSource." + dsName + ".user", jdbcUserName); result.setProperty("org.quartz.dataSource." + dsName + ".password", jdbcPassword); return result; }
Example 3
Source File: RobotScheduledConfig.java From Almost-Famous with MIT License | 6 votes |
@Bean public SchedulerFactoryBean schedulerFactoryBean() throws IOException { //获取配置属性 PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); //在quartz.properties中的属性被读取并注入后再初始化对象 propertiesFactoryBean.afterPropertiesSet(); //创建SchedulerFactoryBean SchedulerFactoryBean factory = new SchedulerFactoryBean(); factory.setQuartzProperties(propertiesFactoryBean.getObject()); //使用数据源,自定义数据源 factory.setJobFactory(jobFactory); factory.setWaitForJobsToCompleteOnShutdown(true);//这样当spring关闭时,会等待所有已经启动的quartz job结束后spring才能完全shutdown。 factory.setOverwriteExistingJobs(false); factory.setStartupDelay(1); return factory; }
Example 4
Source File: SSLConfig.java From micro-server with Apache License 2.0 | 6 votes |
@Bean public static SSLProperties sslProperties() throws IOException { PropertiesFactoryBean factory = new PropertiesFactoryBean(); URL url = SSLConfig.class.getClassLoader().getResource("ssl.properties"); if (url != null) { Resource reource = new UrlResource(url); factory.setLocation(reource); factory.afterPropertiesSet(); Properties properties = factory.getObject(); return SSLProperties.builder() .keyStoreFile(properties.getProperty(keyStoreFile)) .keyStorePass(properties.getProperty(keyStorePass)) .trustStoreFile(properties.getProperty(trustStoreFile)) .trustStorePass(properties.getProperty(trustStorePass)) .keyStoreType(properties.getProperty(keyStoreType)) .keyStoreProvider(properties.getProperty(keyStoreProvider)) .trustStoreType(properties.getProperty(trustStoreType)) .trustStoreProvider(properties.getProperty(trustStoreProvider)) .clientAuth(properties.getProperty(clientAuth)) .ciphers(properties.getProperty(ciphers)) .protocol(properties.getProperty(protocol)).build(); } return null; }
Example 5
Source File: QuartzSchedulerConfig.java From spring-boot-quartz-demo with MIT License | 5 votes |
/** * Configure quartz using properties file */ @Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 6
Source File: SchedulerConfig.java From quartz-manager with Apache License 2.0 | 5 votes |
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 7
Source File: QuartzConfig.java From lemonaid with MIT License | 5 votes |
@Bean public Properties quartzProperties() { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); Properties properties = null; try { propertiesFactoryBean.afterPropertiesSet(); properties = propertiesFactoryBean.getObject(); } catch (IOException e) { log.warn("Cannot load quartz.properties."); } return properties; }
Example 8
Source File: SchedulerConfig.java From springboot-quartz with MIT License | 5 votes |
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 9
Source File: TestContextConfiguration3.java From spring-boot-starter-quartz with Apache License 2.0 | 5 votes |
@Bean(name = QuartzSchedulerAutoConfiguration.QUARTZ_PROPERTIES_BEAN_NAME) public Properties quartzProperties( @Autowired ApplicationContext applicationContext, @Autowired QuartzSchedulerProperties properties) throws IOException { System.out.println("my overridden quartz.properties loading"); PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(applicationContext.getResource("classpath:overriddenQuartzScheduler.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 10
Source File: QuartzSchedulerAutoConfiguration.java From spring-boot-starter-quartz with Apache License 2.0 | 5 votes |
private static Properties loadConfigLocationProperties(ApplicationContext applicationContext, QuartzSchedulerProperties properties) throws IOException { String location = properties.getPropertiesConfigLocation(); if(null == location || location.trim().length() == 0) { location = QuartzSchedulerProperties.DEFAULT_CONFIG_LOCATION; LOGGER.debug("using default 'quartz.properties' from classpath: " + location); } else { LOGGER.debug("using 'quartz.properties' from location: " + location); } PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(applicationContext.getResource(location)); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 11
Source File: SchedulerConfig.java From ehousechina with Apache License 2.0 | 5 votes |
@Bean public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource, JobFactory jobFactory, @Qualifier("sampleJobTrigger") Trigger sampleJobTrigger) throws IOException { SchedulerFactoryBean factory = new SchedulerFactoryBean(); factory.setOverwriteExistingJobs(true); factory.setDataSource(dataSource); factory.setJobFactory(jobFactory); PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); factory.setQuartzProperties(propertiesFactoryBean.getObject()); return factory; }
Example 12
Source File: SchedulerConfig.java From spring-boot-demo with MIT License | 5 votes |
/** * 加载配置属性 * * @return * @throws IOException */ @Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/spring-quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 13
Source File: PropertiesUtil.java From griffin with Apache License 2.0 | 5 votes |
public static Properties getProperties(String path, Resource resource) { PropertiesFactoryBean propFactoryBean = new PropertiesFactoryBean(); Properties properties = null; try { propFactoryBean.setLocation(resource); propFactoryBean.afterPropertiesSet(); properties = propFactoryBean.getObject(); LOGGER.info("Read properties successfully from {}.", path); } catch (IOException e) { LOGGER.error("Get properties from {} failed. {}", path, e); } return properties; }
Example 14
Source File: QuartzConfigration.java From yyblog with MIT License | 5 votes |
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/config/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 15
Source File: SchedulerConfig.java From TAC with MIT License | 5 votes |
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); //在quartz.properties中的属性被读取并注入后再初始化对象 propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 16
Source File: SchedulerConfig.java From zkdoctor with Apache License 2.0 | 5 votes |
/** * 初始化quartz配置 * * @return * @throws IOException */ @Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 17
Source File: PacmanQuartzConfiguration.java From pacbot with Apache License 2.0 | 5 votes |
@Bean public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }
Example 18
Source File: BootMailSenderAwsTest.java From spring-cloud-aws with Apache License 2.0 | 4 votes |
@Bean(name = "mail") public PropertiesFactoryBean mail() { PropertiesFactoryBean factoryBean = new PropertiesFactoryBean(); factoryBean.setLocation(this.mailConfigResource); return factoryBean; }
Example 19
Source File: QrtzScheduler.java From tutorials with MIT License | 4 votes |
public Properties quartzProperties() throws IOException { PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean(); propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties")); propertiesFactoryBean.afterPropertiesSet(); return propertiesFactoryBean.getObject(); }