草庐IT

ConfigurationProperties

全部标签

spring - Kotlin Spring boot @ConfigurationProperties 用于列表

我想使用Kotlin读取yaml配置文件,下面是我的代码:application.ymlmessage:messages:-name:abctype:aaasize:10-name:xyztype:bbbsize:20MessageConfig.ktpackagecom.example.demokotlinimportorg.springframework.boot.context.properties.ConfigurationPropertiesimportorg.springframework.context.annotation.Configurationimportjava.

java - 不可变的@ConfigurationProperties

SpringBoot的@ConfigurationProperties是否可以拥有不可变(最终)字段?注解?下面的例子@ConfigurationProperties(prefix="example")publicfinalclassMyProps{privatefinalStringneededProperty;publicMyProps(StringneededProperty){this.neededProperty=neededProperty;}publicStringgetNeededProperty(){..}}到目前为止我尝试过的方法:创建@Bean的MyProps具有

java - 不可变的@ConfigurationProperties

SpringBoot的@ConfigurationProperties是否可以拥有不可变(最终)字段?注解?下面的例子@ConfigurationProperties(prefix="example")publicfinalclassMyProps{privatefinalStringneededProperty;publicMyProps(StringneededProperty){this.neededProperty=neededProperty;}publicStringgetNeededProperty(){..}}到目前为止我尝试过的方法:创建@Bean的MyProps具有

spring-boot - @ConfigurationProperties Spring Boot 配置注释处理器在类路径中找不到

我尝试在SpringBoot中完成自定义属性。我尝试通过IntelliJIDEA2016.3创建一个简单的项目:使用SpringBootInitializer创建了一个新的Gradle项目(我根本没有检查任何东西)。创建了一个新类Properties。当我用@ConfigurationProperties对其进行注释时,出现了下一个通知:Thedocumentation说我应该在我的项目中添加以下内容:dependencies{optional"org.springframework.boot:spring-boot-configuration-processor"}compileJa

spring-boot - @ConfigurationProperties Spring Boot 配置注释处理器在类路径中找不到

我尝试在SpringBoot中完成自定义属性。我尝试通过IntelliJIDEA2016.3创建一个简单的项目:使用SpringBootInitializer创建了一个新的Gradle项目(我根本没有检查任何东西)。创建了一个新类Properties。当我用@ConfigurationProperties对其进行注释时,出现了下一个通知:Thedocumentation说我应该在我的项目中添加以下内容:dependencies{optional"org.springframework.boot:spring-boot-configuration-processor"}compileJa

spring - Kotlin 和 Spring Boot @ConfigurationProperties

如何使用Kotlin在SpringBoot中正确初始化ConfigurationProperties?目前我喜欢下面的例子:@ConfigurationProperties("app")classConfig{varfoo:String?=null}但它看起来很丑,实际上foo不是variable,foo是constantvalue应该在启动时初始化,以后不会改变。 最佳答案 使用新的SpringBoot2.2,您可以这样做:@ConstructorBinding@ConfigurationProperties(prefix="sw

spring - Kotlin 和 Spring Boot @ConfigurationProperties

如何使用Kotlin在SpringBoot中正确初始化ConfigurationProperties?目前我喜欢下面的例子:@ConfigurationProperties("app")classConfig{varfoo:String?=null}但它看起来很丑,实际上foo不是variable,foo是constantvalue应该在启动时初始化,以后不会改变。 最佳答案 使用新的SpringBoot2.2,您可以这样做:@ConstructorBinding@ConfigurationProperties(prefix="sw

Spring Boot微服务从yml文件中加载配置(使用@Value和@ConfigurationProperties)

记录:398场景:在SpringBoot的微服务中从application.yml等yml文件中加载自定义配置内容。使用@Value直接加载单个配置。使用@ConfigurationProperties注解把一个或者多个配置加载为Java对象。版本:JDK1.8,SpringBoot2.6.31.使用@Value注解加载配置使用注解@RestController、@Service、@Component等标记的类中,都可以使用@Value注解从yml文件中加载配置取值。1.1在yml文件配置hub:example:city-name:'杭州'1.2使用@Value取值@Value("${hub.

java - 如何使用 @ConfigurationProperties 和 @Autowired 测试类

我想测试依赖于@Autowired和@ConfigurationProperties加载的属性的应用程序的一小部分。我正在寻找一种仅加载所需属性而不总是加载整个ApplicationContext的解决方案。这里作为简化示例:@TestPropertySource(locations="/SettingsTest.properties")@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={TestSettings.class,TestConfiguration.class})publicclassS

java - Spring Boot @ConfigurationProperties 不从环境中检索属性

我正在使用SpringBoot1.2.1并尝试创建一个带有验证的@ConfigurationPropertiesbean,如下所示:packagecom.sampleapp;importjava.net.URL;importjavax.validation.constraints.NotNull;importorg.springframework.boot.context.properties.ConfigurationProperties;importorg.springframework.stereotype.Component;@Component@ConfigurationPr