在實體類里面加上
@PropertySource("classpath:/robot_config.properties")
robot_config.properties // 配置文件的名字
文件放在resources 目錄下
類里面的屬性取值
@Value("${quest_mode}") private String questMode;
properties 里面的屬性
questMode = /ossServer // 這種格式
在代碼里使用,直接注入就可以了
@Resource private RobotConfig robotConfig;
然后直接使用這個對象,在配置文件里面的值就會賦值上去了。