properties-file

Spring boot properties to be loaded at initialization and respect all and control @Aspect based on the value from property file

♀尐吖头ヾ 提交于 2019-12-02 04:15:27
问题 We are loading properties from an external file using @PropertySources . Now I want to enable/disable @Aspect based on a property. I tried using @ConditionalOnExpression which didn't work. I tried the same by creating a bean of propertyplaceholderconfig . Even in the same case, it didn't work. Then I tried @profile which also didn't work initially. What I Figured out is that these variables are not initialized at the starting when propertysource or propertyplaceholder bean is used at startup.

Spring boot properties to be loaded at initialization and respect all and control @Aspect based on the value from property file

淺唱寂寞╮ 提交于 2019-12-02 02:19:47
We are loading properties from an external file using @PropertySources . Now I want to enable/disable @Aspect based on a property. I tried using @ConditionalOnExpression which didn't work. I tried the same by creating a bean of propertyplaceholderconfig . Even in the same case, it didn't work. Then I tried @profile which also didn't work initially. What I Figured out is that these variables are not initialized at the starting when propertysource or propertyplaceholder bean is used at startup. Some variables are always ignored like (logging.file). But @Value works fine. In order to set these

Bash Script Properties File Using '.' in Variable Name

落花浮王杯 提交于 2019-12-01 17:53:03
问题 I'm new to bash scripting and have a question about using properties from a .properties file within a bash script. I have seen a bash properties file that uses'.' between variable names, for example: this.prop.one=someProperty and I've seen them called from within a script like: echo ${this.prop.one} But when I try to set this property I get an error: ./test.sh: line 5: ${this.prop.one}: bad substitution I can use properties if I do it without '.' in the variable names, and include the props

How to escape special characters in the key of properties file?

允我心安 提交于 2019-12-01 17:11:36
问题 I've got a key = value property in the .properties file: give names: (1) code = xxx ... but when I tried to get that key, it threw an error: No message found under code give names: (1) code = xxx I tried escaping the whitespace with \ but it didn't work. Do I need to escape : , ( , and ) characters as well? 回答1: You could check out: http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader) For info on how java interprets a properties file. The most relevant part

Spring Boot default properties encoding change?

我的未来我决定 提交于 2019-12-01 09:15:40
I am trying to find a way to set UTF-8 encoding for properties accessed via @Value annotation from application.property files in Spring boot. So far I have been successfully set encoding to my own properties sources by creating a bean: @Bean @Primary public PropertySourcesPlaceholderConfigurer placeholderConfigurer(){ PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setLocation(new ClassPathResource("app.properties"); configurer.setFileEncoding("UTF-8"); return configurer; } Such solution presents two problems. For once, it does NOT work

How to show a property loaded from properties file in JSF page

帅比萌擦擦* 提交于 2019-12-01 08:33:35
Is it possible, in a JSF page, to show a property loaded from a project.properties file (for example the database name)? In project.properties : cfg.bd.dbname=midatabase-name In some jsf page some expression similar to this: <h:outputText value="#{cfg.bd.dbname}" /> Thanks! You can (ab)use <f:loadBundle> for this. <f:loadBundle basename="project" var="project" /> ... <h:outputText value="#{project['cfg.bd.dbname']} /> I said abuse , because the <f:loadBundle> is initially intented to load localized text bundles which allows for internationalization, but as it's under the covers using the same

Spring boot yml ResourceBundle file

有些话、适合烂在心里 提交于 2019-12-01 03:08:01
I'm using MessageSource of Spring to load errors messages from a .properties file in classpath. My properties respect a certain "template" such as {Object}.{field}.{unrespectedConstraint} Example : userRegistrationDto.password.Size= Le mot de passe doit avoir au minimum 6 caractères. userRegistrationDto.email.ValidEmail= Merci de saisir une addresse mail valide. In case of refactoring (Changing the name of the class for example), I have to change my properties file in several places. Is there any way to use a yaml file (messages.yml) as a ResourceBundle to obtain something like :

Read common external property file in Java Webapp and java normal app

泪湿孤枕 提交于 2019-12-01 02:37:57
I know this question has answered many a time with most useful answer as below, Where to place and how to read configuration resource files in servlet based application? However, We have some special requirement as below, Webapp will be deployed to tomcat. Normal java app in form of .jar will be placed under folder /myapp myappConfig.property file will be placed under /myapp Directory Structure on client machine /myapp /myapp.jar /assests/myappConfig.property /tomcat/webapps/myapp.war Basically myapp.jar and myapp.war will access sql db connection values for MySql database connection and db

Add properties file to build path of runnable jar

£可爱£侵袭症+ 提交于 2019-12-01 01:22:44
is it possible to add to the classpath of a runnable jar file some properties file? I tryed these solutions solutions: running the executable file using the following command: java -cp ../prop_dir/prop1.properties;../prop_dir/prop2.properties -jar MyRunnableJar.jar adding to the MANIFEST FILE (in the Class-Path section) ../prop_dir/prop1.properties ../prop_dir/prop1.properties but none of them works. The architecture of the running dir is the following + + MyRunnableJar.jar + prop_dir/ + prop1.properties + prop2.properties Thanks so much, Daniele EDIT When I execute the following line System

Spring @Scheduled cron details from property file - Exception

流过昼夜 提交于 2019-12-01 00:24:21
I was trying to define the cron details in my spring @Scheduled method @Service @PropertySource("classpath:application.properties") public class CacheRefreshService { @Scheduled(cron = "${api.refresh.cron}") public void refreshJob() throws Exception { LOGGER.info("Started Refresh"); //do something } } And in my application.properties #Refresh api.refresh.cron =0 29 11 * * ? When I define the cron details along with @Scheduled, it is running fine. But when I do this, it is not able to read the value from the properties file and the below error is thrown. Caused by: java.lang