Beispiel #1
0
 @Bean
 public static PropertySourcesPlaceholderConfigurer prodPropertiesPlaceholderConfigurer() {
   PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer();
   Resource[] resourceLocations = new Resource[] {new ClassPathResource(DATABASE_PROPERTIES_FILE)};
   p.setLocations(resourceLocations);
   return p;
 }
 @Bean
 public PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() {
   PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer();
   Resource[] resourceLocations =
       new Resource[] {
         new ClassPathResource("system.properties"), new ClassPathResource("my.properties"),
       };
   p.setLocations(resourceLocations);
   return p;
 }
 @Bean
 public static PropertySourcesPlaceholderConfigurer properties() {
   PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
   Resource[] resources =
       new FileSystemResource[] {
         new FileSystemResource("src/main/app-dirs/x509annotationdir/conf/etomcat.properties")
       };
   pspc.setLocations(resources);
   // pspc.setIgnoreUnresolvablePlaceholders(true);
   return pspc;
 }
Beispiel #4
0
 @Bean
 public static PropertySourcesPlaceholderConfigurer properties() {
   PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
   Resource[] resources =
       new FileSystemResource[] {
         new FileSystemResource(System.getProperty("user.home") + "/molgenis-server.properties")
       };
   pspc.setLocations(resources);
   pspc.setIgnoreUnresolvablePlaceholders(true);
   pspc.setIgnoreResourceNotFound(true);
   return pspc;
 }
 @Bean
 public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
   String propertyFilePath =
       Constants.CONFIG_PATH
           + File.separator
           + "config"
           + File.separator
           + "scoremaker.properties";
   File f = new File(propertyFilePath);
   if (!f.exists()) {
     propertyFilePath = "config" + File.separator + "scoremaker.properties";
   }
   PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =
       new PropertySourcesPlaceholderConfigurer();
   org.springframework.core.io.Resource[] properties =
       new FileSystemResource[] {new FileSystemResource(propertyFilePath)};
   propertySourcesPlaceholderConfigurer.setLocations(properties);
   return propertySourcesPlaceholderConfigurer;
 }
 /**
  * Necessary to make the @Value annotations work. for @Value When use @DependsOn must use small
  * letter like "AppSetup" of a AppSetup.class bean name. relative reference -
  * http://stackoverflow.com/questions/5314513/standard-naming-to-the-spring-beans
  *
  * @return
  */
 @Bean
 @DependsOn("appSetup") // !! bean name convention is important for depends-on
 public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
   PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
   Resource[] locations = null;
   locations =
       new Resource[] {
         //	new PathResource(Files.exists(AppSetup.configPath.resolve("redis.properties")) == true
         // ?
         //			AppSetup.configPath.resolve("redis.properties") :
         // AppSetup.configPath.resolve("redis.properties.default")),
         new PathResource(
             Files.exists(AppSetup.configPath.resolve("mysql.properties")) == true
                 ? AppSetup.configPath.resolve("mysql.properties")
                 : AppSetup.configPath.resolve("mysql.properties.default")),
         new PathResource(
             Files.exists(AppSetup.configPath.resolve("gcrawler.properties")) == true
                 ? AppSetup.configPath.resolve("gcrawler.properties")
                 : AppSetup.configPath.resolve("gcrawler.properties.default")),
       };
   configurer.setLocations(locations);
   return configurer;
 }
 @Override
 public void postProcessBeanFactory(ConfigurableListableBeanFactory arg0) throws BeansException {
   System.out.println("Load file paths");
   StandardEnvironment env = arg0.getBean(StandardEnvironment.class);
   MutablePropertySources propSources = env.getPropertySources();
   for (String filePath : filePaths()) {
     Resource res = resourceLoader.getResource(filePath);
     if (res.exists() && res != null) {
       try {
         Properties props = PropertiesLoaderUtils.loadProperties(res);
         // PropertySourcesLoader l = new PropertySourcesLoader();
         // l.load(new ClassPathResource(filePath));
         PropertiesPropertySource source = new PropertiesPropertySource("app", props);
         System.out.printf("Props loaded from %s is %s\n", filePath, props.toString());
         propSources.addFirst(source);
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
   super.setPropertySources(propSources);
   super.postProcessBeanFactory(arg0);
 }
 @Bean
 public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
   PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
   configurer.setFileEncoding("UTF-8");
   return configurer;
 }