获取properties文件的内容
public void test() throws Exception{ String resource = "application.properties";//resources文件夹中配置文件的路径 InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resource); Properties properties=new Properties(); properties.load(inputStream); System.out.println(properties.getProperty("server.port")); }