configurationproperty

Spring RoutingDataSource validationQuery is not being injected

◇◆丶佛笑我妖孽 提交于 2020-01-04 06:07:45
问题 I'm using RoutingDataSource to dynamically create datasources for each tenant of our application. After 8 - 12 hours application application losts connection with database and I'm getting jpa transaction exception. I found that the following properties are responsible for validation and sustaining database connection so I placed them in my application.properties. spring.datasource.initialize=false spring.datasource.test-while-idle=true spring.datasource.test-on-borrow=true spring.datasource

Spring-boot: set default value to configurable properties

此生再无相见时 提交于 2019-12-05 09:54:04
问题 I have a properties class below in my spring-boot project. @Component @ConfigurationProperties(prefix = "myprefix") public class MyProperties { private String property1; private String property2; // getter/setter } Now, I want to set default value to some other property in my application.properties file for property1 . Similar to what below example does using @Value @Value("${myprefix.property1:${somepropety}}") private String property1; I know we can assign static value just like in example

.net Custom Configuration How to case insensitive parse an enum ConfigurationProperty

天大地大妈咪最大 提交于 2019-12-04 09:50:14
问题 One of the ConfigurationProperty I have in my ConfigurationSection is an ENUM. When .net parses this enum string value from the config file, an exception will be thrown if the case does not match exactly. Is there away to ignore case when parsing this value? 回答1: You can use ConfigurationConverterBase to make a custom configuration converter, see http://msdn.microsoft.com/en-us/library/system.configuration.configurationconverterbase.aspx this will do the job: public class

Spring-boot: set default value to configurable properties

别说谁变了你拦得住时间么 提交于 2019-12-03 22:27:49
I have a properties class below in my spring-boot project. @Component @ConfigurationProperties(prefix = "myprefix") public class MyProperties { private String property1; private String property2; // getter/setter } Now, I want to set default value to some other property in my application.properties file for property1 . Similar to what below example does using @Value @Value("${myprefix.property1:${somepropety}}") private String property1; I know we can assign static value just like in example below where "default value" is assigned as default value for property , @Component

.net Custom Configuration How to case insensitive parse an enum ConfigurationProperty

被刻印的时光 ゝ 提交于 2019-12-03 04:09:50
One of the ConfigurationProperty I have in my ConfigurationSection is an ENUM. When .net parses this enum string value from the config file, an exception will be thrown if the case does not match exactly. Is there away to ignore case when parsing this value? You can use ConfigurationConverterBase to make a custom configuration converter, see http://msdn.microsoft.com/en-us/library/system.configuration.configurationconverterbase.aspx this will do the job: public class CaseInsensitiveEnumConfigConverter<T> : ConfigurationConverterBase { public override object ConvertFrom( ITypeDescriptorContext