程序员的资源宝库

网站首页 > gitee 正文

java注入配置文件

sanyeah 2024-04-12 17:41:18 gitee 7 ℃ 0 评论

`package com.xkcoding.properties.controller;

import cn.hutool.core.lang.Dict;
import com.xkcoding.properties.property.ApplicationProperty;
import com.xkcoding.properties.property.DeveloperProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PropertyController {
private final ApplicationProperty applicationProperty;
private final DeveloperProperty developerProperty;

@Autowired
public PropertyController(ApplicationProperty applicationProperty, DeveloperProperty developerProperty) {
    this.applicationProperty = applicationProperty;
    this.developerProperty = developerProperty;
}

@GetMapping("/property")
public Dict index() {
    return Dict.create().set("a", applicationProperty).set("d", developerProperty);
}`

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表