java spring boot 读取 application.properties
import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import java.io.IOException; import java.util.Properties; public class ApplicationHelper { public static String getPropertyValue(String key) throws IOException { ResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource = resourceLoader.getResource("application.properties"); Properties properties = new Properties(); properties.load(resource.getInputStream()); return properties.getProperty(key); } }
桂棹兮兰桨,击空明兮溯流光。