Refine search
@Configuration @PropertySource("classpath:/batch-hsql.properties") public class DataSourceConfiguration { @Autowired private Environment environment; @Autowired private ResourceLoader resourceLoader;
/** * @author Thomas Risberg */ @Configuration @EnableTransactionManagement @ComponentScan @PropertySource("classpath:jdbc.properties") class ApplicationConfig { @Autowired Environment env; @Bean public DataSource dataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(env.getProperty("jdbc.driverClassName")); ds.setUrl(env.getProperty("jdbc.url")); ds.setUsername(env.getProperty("jdbc.username")); ds.setPassword(env.getProperty("jdbc.password")); return ds; } @Bean public PlatformTransactionManager transactionManager() { DataSourceTransactionManager txManager = new DataSourceTransactionManager(); txManager.setDataSource(dataSource()); return txManager; } }
@Configuration @EnableDubbo(scanBasePackages = "org.apache.dubbo.demo.consumer.comp") @PropertySource("classpath:/spring/dubbo-consumer.properties") @ComponentScan(value = {"org.apache.dubbo.demo.consumer.comp"}) static class ConsumerConfiguration { } }
@Configuration @ComponentScan @PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true) public class Application { @Value("${server.port:8080}") private int port = 8080; public static void main(String[] args) throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( Application.class)) { context.getBean(HttpServer.class).bindNow().onDispose().block(); } } @Profile("default") @Bean public HttpServer nettyHttpServer(ApplicationContext context) { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create().host("localhost").port(this.port); return httpServer.handle(adapter); } }
@Configuration @EnableDubbo(scanBasePackages = "org.apache.dubbo.demo.provider") @PropertySource("classpath:/spring/dubbo-provider.properties") static class ProviderConfiguration { @Bean public RegistryConfig registryConfig() { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setAddress("multicast://224.5.6.7:1234"); return registryConfig; } } }
@Configuration @Profile("rpc-client") @ComponentScan({"com.devicehive.shim.config", "com.devicehive.shim.kafka.topic"}) @PropertySource("classpath:kafka.properties") public class KafkaRpcClientConfig { @Value("${response.topic.perfix}") private String responseTopicPrefix; @Autowired private Environment env; @Autowired private KafkaRpcConfig kafkaRpcConfig; @Autowired private KafkaTopicService kafkaTopicService; @Value("${rpc.client.response-consumer.threads:3}") private int responseConsumerThreads;
/** * @author Mahmoud Ben Hassine */ @Configuration @PropertySource("classpath:remote-partitioning.properties") public class BrokerConfiguration { @Value("${broker.url}") private String brokerUrl; @Bean public ActiveMQConnectionFactory connectionFactory() { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL(this.brokerUrl); connectionFactory.setTrustAllPackages(true); return connectionFactory; } }
@Configuration @EnableBatchProcessing @EnableBatchIntegration @EnableIntegration @PropertySource("classpath:remote-chunking.properties") public class MasterConfiguration { @Value("${broker.url}") private String brokerUrl; @Autowired private JobBuilderFactory jobBuilderFactory; @Autowired private RemoteChunkingMasterStepBuilderFactory masterStepBuilderFactory;
/** * Created by tedonema on 21/03/2016. */ @Configuration @Profile("prod") @PropertySource("file:///${user.home}/.devopsbuddy/application-prod.properties") public class ProductionConfig { @Value("${stripe.prod.private.key}") private String stripeProdKey; @Bean public EmailService emailService() { return new SmtpEmailService(); } @Bean public String stripeKey() { return stripeProdKey; } }
@PropertySource("classpath:remote-chunking.properties") public class RemoteChunkingJobFunctionalTests { @Value("${broker.url}") private String brokerUrl; @Autowired private JobLauncherTestUtils jobLauncherTestUtils;
@Profile({ StarterProfiles.STANDALONE, StarterProfiles.TEST }) @PropertySource("classpath:application-default.properties") // Not loaded by naming convention @Configuration static class StandaloneDatabaseConfig { @Bean public DataSource dataSource(final Environment env) { final HikariDataSource ds = new HikariDataSource(); ds.setJdbcUrl(env.getRequiredProperty("h2.jdbcurl")); ds.setUsername(env.getRequiredProperty("h2.username")); return ds; } }
/** * This is enough to get a Datasource that spring creates using parameters provided in properties. * * @author Emmanuel Duchastenier */ @Component @PropertySource(value = { "classpath:/database.properties", "classpath:/internal.properties" }) @Profile("default") public class GenericDataSourceConfig { }
@SpringBootApplication @EnableJpaAuditing @EnableAsync @EnableScheduling @ComponentScan(value = "com.wikift") @PropertySource(value = { "file:/etc/wikift/wikift.conf" }) public class WikiftServerLaunch { public static void main(String[] args) { SpringApplication.run(WikiftServerLaunch.class, args); } }
private void initModuleConfiguration() { if (!scanModuleConfigurations) { this.moduleDefaultConfiguration = new ConcurrentMapConfiguration(); return; } HashMap<String, Object> base = new HashMap<>(); Set<Class<?>> types = reflections .getTypesAnnotatedWith(PropertySource.class); for (Class<?> type : types) { PropertySource propertySource = type .getAnnotation(PropertySource.class); String[] propertiesFiles = propertySource.value(); for (String propertyFile : propertiesFiles) { Properties properties = new Properties(); try (InputStream is = resourceLoader.getResource(SystemPropertyUtils.resolvePlaceholders(propertyFile)) .getInputStream()) { properties.load(is); LOGGER.debug("Initializing module properties from path " + propertyFile); } catch (Exception e) { BootstrapException.resourceLoadingFailed(propertyFile, e); } join(base, properties, propertyFile, propertiesFiles); } } this.moduleDefaultConfiguration = new ConcurrentMapConfiguration(base); }
@Configuration @EnableJpaRepositories(basePackages = {"io.vertx.examples.spring.repository"}) @PropertySource(value = { "classpath:application.properties" }) @ComponentScan("io.vertx.examples.spring.service") public class ExampleSpringConfiguration { @Autowired private Environment env;
@EnableAspectJAutoProxy @EnableEurekaClient @Configuration @PropertySource(value = {"classpath:adminservice.properties"}) @EnableAutoConfiguration @EnableTransactionManagement @ComponentScan(basePackageClasses = {ApolloCommonConfig.class, ApolloBizConfig.class, AdminServiceApplication.class}) public class AdminServiceApplication { public static void main(String[] args) { SpringApplication.run(AdminServiceApplication.class, args); } }
@Configuration @ComponentScan @PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true) public class Application { @Value("${server.port:8080}") private int port = 8080; public static void main(String[] args) throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( Application.class)) { context.getBean(HttpServer.class).bindNow().onDispose().block(); } } @Profile("default") @Bean public HttpServer nettyHttpServer(ApplicationContext context) { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create().host("localhost").port(this.port); return httpServer.handle(adapter); } }
@Configuration @PropertySource( value = { "classpath:org/springframework/context/annotation/p1.properties", "classpath:org/springframework/context/annotation/p2.properties" }) static class ConfigWithMultipleResourceLocations { }
@Configuration @Profile("rpc-client") @ComponentScan({"com.devicehive.shim.config", "com.devicehive.shim.kafka.topic"}) @PropertySource("classpath:kafka.properties") public class AuthRpcClientConfig { @Value("${response.topic.perfix}") private String responseTopicPrefix; @Autowired private Environment env; @Autowired private KafkaRpcConfig kafkaRpcConfig; @Autowired private KafkaTopicService kafkaTopicService; @Value("${rpc.client.response-consumer.threads:3}") private int responseConsumerThreads;
/** * @author Mahmoud Ben Hassine */ @Configuration @PropertySource("classpath:remote-partitioning.properties") public class DataSourceConfiguration { @Value("${datasource.url}") private String url; @Value("${datasource.username}") private String username; @Value("${datasource.password}") private String password; @Bean public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); return dataSource; } }