public static int getPortFromConfigFile() throws IOException {

        int port = 8080;
        File configFile = null;
        File startupConfigFile = getConfigFromStartup();
        if (null != startupConfigFile) {
            configFile = startupConfigFile;
        } else {
            try {
                File propertiesFile = ResourceUtils.getFile("classpath:application.properties");
                configFile = propertiesFile;
            } catch (FileNotFoundException exx) {
                File ymlFile = ResourceUtils.getFile("classpath:application.yml");
                configFile = ymlFile;
            }
        }
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream(configFile);
            String fileName = configFile.getName();
            String portNum = null;
            if (fileName.endsWith("yml")) {
                Map<String, Object> yamlMap = new Yaml().load(inputStream);
                Map<String, Object> configMap =  MapUtil.getFlattenedMap(yamlMap);
                if (CollectionUtils.isNotEmpty(configMap)) {
                    Object serverPort = configMap.get("server.port");
                    if (null != serverPort) {
                        portNum = serverPort.toString();
                    }
                }
            } else {
                Properties properties = new Properties();
                properties.load(inputStream);
                portNum = properties.getProperty("server.port");
            }
            if (null != portNum) {
                try {
                    port = Integer.parseInt(portNum);
                } catch (NumberFormatException exx) {
                    //ignore
                }
            }
        } finally {
            if (null != inputStream) {
                inputStream.close();
            }
        }
        return port;

    }
@Test
    public void testGetPortFromConfigFile() throws IOException {
        Assertions.assertEquals(7091,PortHelper.getPortFromConfigFile());
    }