在非 Spring-Boot 应用程序中使用 @ConfigurationProperties [英] Working with @ConfigurationProperties in a non Spring-Boot application
本文介绍了在非 Spring-Boot 应用程序中使用 @ConfigurationProperties的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 @ConfigurationProperties 在我的 Spring-MVC 应用程序(非 Spring-Boot)中获取配置绑定.到目前为止,我所做的唯一一件事是将 Maven spring-boot
依赖项添加到我的项目中,以获取 @ConfigurationProperties
类.
I'm trying to get configuration-binding in my Spring-MVC application (non Spring-Boot) enabled using the @ConfigurationProperties. The only thing i did so far, is that I added the Maven spring-boot
dependency to my project, to get the @ConfigurationProperties
class.
@Configuration
@PropertySource("classpath:foo.properties")
@ConfigurationProperties(prefix = "foo")
public class FooConfig{
private String bar;
// ...
}
到目前为止还没有绑定.有没有让绑定继续下去的想法?
So far nothing is binded. Any thoughts to get the binding going?
推荐答案
您需要启用配置属性.
@EnableConfigurationProperties
这篇关于在非 Spring-Boot 应用程序中使用 @ConfigurationProperties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文