将配置项读取到字段上
@Configuration
@Getter
@Setter
public class PropertiesConfig {
@Value("${qizhan.root}")
private String root;
@Value("${qizhan.path}")
private String path;
}
将配置类自动注入
@Slf4j
@Component
public class PropertiesHelper {
@Autowired
public void init(PropertiesConfig config) {
WebConstants.WEB_ROOT = config.getRoot();
WebConstants.PATH = config.getPath();
log.info(WebConstants.WEB_ROOT);
}
}
- 版权所有:奇站网络 转载请注明出处
- 厦门奇站网络科技有限公司,专业提供网站建设,响应式网站建设,小程序开发,系统定制开发。
- 软件开发咨询热线:吴小姐 13313868605