SpringBoot项目配置文件加载与注入集合详解

版权申诉
0 下载量 11 浏览量 更新于2024-03-10 收藏 4.57MB PDF 举报
SpringBoot项目.pdf中介绍了创建项目和获取配置文件中属性值的方法,以及修改配置文件名和路径的方式。可以通过配置方式或者编码方式来实现。通过图示可以看出,有两种加载文件的方式,一种是加载一个文件,另一种是加载多个文件。在注入集合的时候需要注意,集合中必须要有get和set方法,并且集合名要与除前缀之外的属性名相同。在项目初始化的时候,Spring Boot会去加载文件中与前缀相同的属性。在ConfigurationProperties注解中有两个属性,一个是前缀,一个是locations属性。 Overall, the springboot_project .pdf explains how to create a project and obtain property values from configuration files, as well as how to modify the file names and paths. This can be done through either configuration or coding. The document shows two methods for loading files: one for loading a single file, and the other for loading multiple files. When injecting collections, it is important to note that the collection must have get and set methods, and the collection name must be the same as the attribute name excluding the prefix. During initialization, Spring Boot will look for properties in the files that match the specified prefix. The ConfigurationProperties annotation has two attributes: prefix and locations.