Spring Boot读取自定义properties文件

读取application-test.properties配置文件里面的自定义的: privilege.assistor = test

方法1:
@Value("${privilege.assistor}") private String assistorPrivileges;
System.out.println(assistorPrivileges);

方法2:
步骤一:
@Autowired
private Environment env;
步骤二:
env.getProperty("privilege.assistor")

猜你喜欢

转载自blog.csdn.net/c910511/article/details/70182918