如何读取配置性文件信息
来源:互联网 发布:java微信发送消息源码 编辑:程序博客网 时间:2024/04/30 05:31
try {// Properties pro = new Properties();// FileInputStream in = null;// String springConfigLocation = "/data/code/credit-ws-conf/config.properties";// try {//// in = new FileInputStream(springConfigLocation);// pro.load(in);//// } catch (Exception e) {// e.printStackTrace();// }// String strHost = pro.getProperty("spring.mail.host");// String strUsername = pro.getProperty("spring.mail.username");// String strPassword = pro.getProperty("spring.mail.password"); 等于: ServiceEmail sendEmail = emailService.findSendEmailByStatus(StatusCode.EMAIL_VERIFICATION); 配置文件: # Server HTTP port.server.port=8080#dev toolsspring.devtools.livereload.enabled=true# 静态文件请求匹配方式spring.mvc.static-path-pattern=/**# 修改默认的静态寻址资源目录spring.resources.static-locations = classpath:/templates/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/logback.level.admin=INFOlogback.dir.admin=@logback.dir.admin@server.tomcat.accesslog.directory=@logging.dir.admin@server.tomcat.accesslog.prefix=access_admin_logserver.tomcat.accesslog.enabled=truesecurity.require_ssl=false#thymeleafspring.thymeleaf.cache=falsespring.mvc.favicon.enabled=falsespring.aop.auto=truespring.aop.proxy-target-class=falsespring.jackson.parser.ALLOW_UNQUOTED_FIELD_NAMES=true#spring.jackson.serialization.indent-output=true#spring.jackson.parser.ALLOW_SINGLE_QUOTES=truelogback.level.ws=INFOlogback.dir.ws=@logback.dir.ws@#jdbc.driverClassName=com.mysql.jdbc.Driver#jdbc.url=jdbc:mysql://172.24.133.35:3306/credit?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false#jdbc.username=credit_service#jdbc.password=credit_servicejdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://127.0.0.1:3306/credit?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=falsejdbc.username=rootjdbc.password=spring.mail.host=smtp.163.comspring.mail.username=yucongyu@163.comspring.mail.password=yucong123456spring.mail.default-encoding=UTF-8spring.http.multipart.max-file-size=12800KBspring.http.multipart.max-request-size=1280KBlog.httpRestuest=true
阅读全文