configurationproperties

Spring @Validated annotation prevents @ConfigurationProproperties value injection, why?

五迷三道 提交于 2021-02-18 19:32:57
问题 I am trying with @ConfigurationProperties and I find two things: for tests to work, I have to put configuration properties files (yml) in test package; setters and an empty constructor are required. If I annotated the class with @Validated , injection just fails with all null values. If you say the first one is understandable, and the second one? Why? The purpose is to validate configuration properties injection, so that crucial properties values should not be absent when the application

Spring @Validated annotation prevents @ConfigurationProproperties value injection, why?

半腔热情 提交于 2021-02-18 19:31:10
问题 I am trying with @ConfigurationProperties and I find two things: for tests to work, I have to put configuration properties files (yml) in test package; setters and an empty constructor are required. If I annotated the class with @Validated , injection just fails with all null values. If you say the first one is understandable, and the second one? Why? The purpose is to validate configuration properties injection, so that crucial properties values should not be absent when the application

Using Spring Boot 2.2.0's @ConstructorBinding for multiple Beans

与世无争的帅哥 提交于 2021-01-27 22:42:54
问题 So I'm very excited about the new @ConstructorBinding feature but I have a question about how it interacts with @ConfigurationProperties . It is possible to declare multiple beans of the same type with configuration properties by changing the prefix, e.g.: @Bean("myBean1") @ConfigurationProperties("foo.baz") MyBean myBean1(){ return new MyBean(); } @Bean("myBean2") @ConfigurationProperties("foo.bar") MyBean myBean2(){ return new MyBean(); } But as far as I can tell from the documentation, the

Spring Boot read properties without prefix to a map

China☆狼群 提交于 2020-01-04 13:38:32
问题 I need to read all properties in application.properties file in a map In the code below the property test has the respective value but the map is empty. How can I fill "map" with the values in the application.properties file without adding a prefix to the properties. This is my application.properties file AAPL=25 GDDY=65 test=22 I'm using @ConfigurationProperties like this @Configuration @ConfigurationProperties("") @PropertySource("classpath:application.properties") public class

Spring Boot read properties without prefix to a map

蓝咒 提交于 2020-01-04 13:38:22
问题 I need to read all properties in application.properties file in a map In the code below the property test has the respective value but the map is empty. How can I fill "map" with the values in the application.properties file without adding a prefix to the properties. This is my application.properties file AAPL=25 GDDY=65 test=22 I'm using @ConfigurationProperties like this @Configuration @ConfigurationProperties("") @PropertySource("classpath:application.properties") public class

Spring Boot read properties without prefix to a map

孤街浪徒 提交于 2020-01-04 13:38:03
问题 I need to read all properties in application.properties file in a map In the code below the property test has the respective value but the map is empty. How can I fill "map" with the values in the application.properties file without adding a prefix to the properties. This is my application.properties file AAPL=25 GDDY=65 test=22 I'm using @ConfigurationProperties like this @Configuration @ConfigurationProperties("") @PropertySource("classpath:application.properties") public class

Polymorphic configuration properties in Spring Boot

限于喜欢 提交于 2019-12-06 00:32:20
问题 I would like to use polymorphic configuration properties on Spring, using Spring's @ConfigurationProperties annotation. Suppose we have the following POJO classes. public class Base { private String sharedProperty; public String getSharedProperty() { return sharedProperty; } public String setSharedProperty(String sharedProperty) { this.sharedProperty = sharedProperty; } } public class Foo extends Base { private String fooProperty; public String getFooProperty() { return fooProperty; } public

Polymorphic configuration properties in Spring Boot

流过昼夜 提交于 2019-12-04 07:58:47
I would like to use polymorphic configuration properties on Spring, using Spring's @ConfigurationProperties annotation. Suppose we have the following POJO classes. public class Base { private String sharedProperty; public String getSharedProperty() { return sharedProperty; } public String setSharedProperty(String sharedProperty) { this.sharedProperty = sharedProperty; } } public class Foo extends Base { private String fooProperty; public String getFooProperty() { return fooProperty; } public String setFooProperty(String sharedProperty) { this. fooProperty = fooProperty; } } public class Bar