当前位置: 首页 > news >正文

品牌型网站建设方案黄页网站推广app咋做广告

品牌型网站建设方案,黄页网站推广app咋做广告,网络服务模型,WordPress巨卡无比目录 一,SpringBoot配置文件 1,配置文件的格式: 2,properties 3,yml 1,properties与yml的转换 2,读取配置选哪个中的内容 3,单双引号的差异: 4,配置对象: 5,配置集合/配置map 6,yml的优缺点: 二,验证码: 学习目的: 实现样例: 接口定义: 代码总结: 三,日志: 1,概…

目录

一,SpringBoot配置文件

1,配置文件的格式:

2,properties

3,yml

1,properties与yml的转换

2,读取配置选哪个中的内容

3,单双引号的差异:

4,配置对象:

5,配置集合/配置map

6,yml的优缺点:

二,验证码:

学习目的:

实现样例:

接口定义:

代码总结:

三,日志:

1,概述

2,打印日志:

3,日志的框架:门面模式

4,日志级别分类:

5,日志持久化:

6,配置文件分割:

7,其他配置项

8,注解输出日志:


一,SpringBoot配置文件

配置⽂件主要是为了解决硬编码带来的问题,把可能会发⽣改变的信息,放在⼀个集中的地⽅,当我们启 动某个程序时,应⽤程序从配置⽂件中读取数据,并加载运⾏

1,配置文件的格式:

• application.properties

• application.yml

• application.yaml

properties与yml同时存在,同时生效,但是如果配置项有冲突的时,以properties

2,properties

properties 是以键值的形式配置的,key和value之间是以"="连接的,配置⽂件中使⽤“#”来添加注释信息。

my.key1=zhangsan
my.key2=true
my.key3=13
    @Value("${my.key1}")private String key1;@Value("${my.key2}")private String key2;@Value("${my.key3}")private String key3;@PostConstruct//在类加载过程中就会执行public void readValues2(){System.out.println("从配置文件中读取:"+key1);System.out.println("从配置文件中读取:"+key2);System.out.println("从配置文件中读取:"+key3);}

3,yml

yml的全称为yaml,单词之间用:\n分割,key和Value之间用':<空格>',注意:空格不可以省略

1,properties与yml的转换

#properties
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/testdb?characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=root

properties转yml,把 '.' 转化为 ':\n'

yml转properties,把 ':\n' 转化为 '.'

#yml
spring:datasource:url: jdbc:mysql://127.0.0.1:3306/testdb?characterEncoding=utf8&useSSL=falseusername: rootpassword: root

2,读取配置选哪个中的内容

@RestController
public class YmlController {@Value("${spring.datasource.url}")public String url;@Value("${spring.datasource.username}")public String username;@Value("${spring.datasource.password}")public String password;@PostConstructpublic void readValue(){System.out.println("yml配置文件:"+url);System.out.println("yml配置文件:"+username);System.out.println("yml配置文件:"+password);}}

空字符串直接后面什么都不加就可以,但是这种方式不直观,更多的表示使用引号括起来,null用~代表null

3,单双引号的差异:

string:str1: Hello \n Spring Boot.str2: 'Hello \n Spring Boot.'str3: "Hello \n Spring Boot."

字符串默认不用加上单引号或者双引号,加上双引号后转义字符会执行

4,配置对象:

#yml
student:id: 1name: Javaage: 18@Configuration
@Data
@ConfigurationProperties(prefix = "student")
public class StudentConfig {private Integer id;private String name;private Integer age;
}@Autowiredpublic StudentConfig studentConfig;@PostConstructpublic void readValue(){System.out.println(studentConfig.toString());}

5,配置集合/配置map

#yml
student:id: 1name: Javaage: 18dbtype:- mysql- sqlServer- oraclemap:k1: kk1k2: kk2k3: kk3package com.ABdolphin.ioc.config;
@Configuration
@Data
@ConfigurationProperties(prefix = "student")
public class StudentConfig {private Integer id;private String name;private Integer age;private List<String> dbtype;private Map<String,String> map;
}package com.ABdolphin.ioc.Contraller;
@RestController
public class YmlController {@Autowiredpublic StudentConfig studentConfig;@PostConstructpublic void readValue(){System.out.println(studentConfig.toString());}}

6,yml的优缺点:

优点:可读性高,写法简单,易于理解

缺点:

但是不适合写复杂的配置

对格式有较强的要求

二,验证码:

学习目的:

1,学习查看第三方工具的文档

2,学习验证码的实现逻辑

3,练习配置项和代码能力

实现样例:

接口定义:

1,生成验证码2,校验验证码是否正确
URL/captcha/getCaptcha/captcha/check
请求参数无参captcha
响应验证码图片内容true/false

由于为后端代码练习,所以前端代码不进行过多赘述

我们可以借助工具:Hutool是⼀个Java⼯具包类库,对⽂件、流、加密解密、转码、正则、线程、XML等JDK⽅法进⾏封 装,组成各种Util⼯具类. Hutool是⼀个⼩⽽全的Java⼯具类库,通过静态⽅法封装,降低相关API的学习成本,提⾼⼯作效 率,使Java拥有函数式语⾔般的优雅,

Hutool官⽹:https://hutool.cn/

代码总结:

yml:

spring:application:name: captcha-demo
captcha:width: 100height: 50VALID_TIME_OUT: 60000session:key: SESSION_CAPTCHA_KEYdate: SESSION_CAPTCHA_DATE
package com.ABdolphin.captcha.model;@Data
@Configuration
@ConfigurationProperties(prefix = "captcha")
public class CaptchaProperties {private Integer width;private Integer height;private long VALID_TIME_OUT;private Session session;@Datapublic static class Session{private String key;private String date;}}
package com.ABdolphin.captcha.controller;@RestController
@RequestMapping("/captcha")
public class CaptchaController {private static Logger logger= LoggerFactory.getLogger(CaptchaController.class);@Autowiredprivate CaptchaProperties captchaProperties;@GetMapping("/getCaptcha")public void captcha(HttpSession session,HttpServletResponse response){//生成验证码LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(captchaProperties.getWidth(), captchaProperties.getHeight());//打印验证码String code=lineCaptcha.getCode();System.out.println("System随机生成验证码:"+code);logger.info("logger随机生成验证码:"+code);//存储 Sessionsession.setAttribute(captchaProperties.getSession().getKey(),code);session.setAttribute(captchaProperties.getSession().getDate(),new Date());try {lineCaptcha.write((response.getOutputStream()));response.setContentType("image/jpeg");response.setCharacterEncoding("UTF-8");response.setHeader("Pragma","No-cache");} catch (IOException e) {throw new RuntimeException(e);}}@RequestMapping("/check")public boolean check(String captcha,HttpSession session){System.out.println("用户输入的验证码:"+captcha);if (!StringUtils.hasLength(captcha)){return false;}String code=(String) session.getAttribute(captchaProperties.getSession().getKey());Date date = (Date) session.getAttribute(captchaProperties.getSession().getDate());if (date==null||(System.currentTimeMillis()-date.getTime())>captchaProperties.getVALID_TIME_OUT()){return false;}return captcha.equalsIgnoreCase(code);}
}

三,日志:

1,概述

通过打印⽇志来发现和定位问题,或者根据⽇志来分析程序的运⾏过程.⽇志主要是为了发现问题,分析问题,定位问题的,但除此之外,⽇志还有很多⽤途.

1). 系统监控

监控现在⼏乎是⼀个成熟系统的标配, 我们可以通过⽇志记录这个系统的运⾏状态,每⼀个⽅法的响应 时间,响应状态等,对数据进⾏分析,设置不同的规则,超过阈值时进⾏报警.⽐如统计⽇志中关键字的数量,并在关键字数量达到⼀定条件时报警,这也是⽇志的常⻅需求之⼀

2),数据采集

统计⻚⾯的浏览量,访客量,点击量等

2,打印日志:

在程序中获得日志的对象,导入的是这个包,不要导错包!!

 private static Logger logger= LoggerFactory.getLogger(CaptchaController.class);logger.info("logger随机生成验证码:"+code);

3,日志的框架:门面模式

采用门面模式(外观模式),即提供了一个统一的接口,用来访问系统中的一群子接口,其主要特征是定义了⼀个⾼层接⼝,让⼦系统更容易使⽤

SLF4J不同于其他⽇志框架,它不是⼀个真正的⽇志实现,⽽是⼀个抽象层,对⽇志框架制定的⼀种规范, 标准,接⼝.所有SLF4J并不能独⽴使⽤,需要和具体的⽇志框架配合使⽤

SLF4J就是这个⽇志⻔⾯.不同⽇志框架的API接⼝和配置⽂件不同,如果多个⽇志框架共存,那么不得不维护多套配置⽂件, 如果要更换⽇志框架,应⽤程序将不得不修改代码,并且修改过程中可能会存在⼀些代码冲突.引⼊⻔⾯⽇志框架之后,应⽤程序和⽇志框架(框架的具体实现)之间有了统⼀的API接⼝(⻔⾯⽇志框架 实现),此时应⽤程序只需要维护⼀套⽇志⽂件配置,且当底层实现框架改变时,也不需要更改应⽤程序代码.

门面模式的优点:

(1)减少了系统的相互依赖.实现了客⼾端与⼦系统的耦合关系,这使得⼦系统的变化不会影响到调⽤它 的客⼾端

(2)提⾼了灵活性,简化了客⼾端对⼦系统的使⽤难度,客⼾端⽆需关⼼⼦系统的具体实现⽅式,⽽只需 要和⻔⾯对象交互即可

(3)提⾼了安全性.可以灵活设定访问权限,不在⻔⾯对象中开通⽅法,就⽆法访问

4,日志级别分类:

从⾼到低依次为:FATAL、ERROR、WARN、INFO、DEBUG、TRACE

• FATAL:致命信息,表⽰需要⽴即被处理的系统级错误.

• ERROR:错误信息,级别较⾼的错误⽇志信息,但仍然不影响系统的继续运⾏. • WARN:警告信息,不影响使⽤,但需要注意的问题

• INFO:普通信息,⽤于记录应⽤程序正常运⾏时的⼀些信息,例如系统启动完成、请求处理完成等. • DEBUG:调试信息,需要调试时候的关键信息打印.

• TRACE:追踪信息,⽐DEBUG更细粒度的信息事件(除⾮有特殊⽤意,否则请使⽤DEBUG级别替代)

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/logger")
public class LoggerController {public static Logger logger= LoggerFactory.getLogger(LoggerController.class);@RequestMapping("/logger1")public String logger(){logger.error("=========error=========");logger.warn("=========warn=========");logger.info("=========info=========");logger.debug("=========debug=========");logger.trace("=========trace=========");return "日志打印";}
}

这里默认的配置级别info及以上的日志,也可以将其在配置文件中进行改变

yml配置:

logging:level:root: debug

5,日志持久化:

配置日志的储存目录:

logging.file.name

logging.file.path

logging.file.name 和 logging.file.path 两个都配置的情况下,只⽣效其⼀,以 logging.file.name 为准

6,配置文件分割:

logging.logback.rollingpolicy.file-name-pattern

logging.logback.rollingpolicy.file-nax-file-size

常见的 Application Properties

logging:level:root: infofile:name: logger/spring-boot-loglogback:rollingpolicy:file-name-pattern: ${LOG_FILE}.%d{yyyy-MM-dd}.%imax-file-size: 1KB

7,其他配置项

改变日志的颜色

重新启动程序就支持颜色了

8,注解输出日志:

1. 添加lombok框架⽀持 2. 使⽤ @slf4j 注解输出⽇志

@RestController
@RequestMapping("/logger")
@Slf4j
public class LoggerController2 {public String logger(){log.error("=========error=========");log.warn("=========warn=========");log.info("=========info=========");log.debug("=========debug=========");log.trace("=========trace=========");return "日志打印";}
}


文章转载自:
http://alienist.bsdw.cn
http://kelson.bsdw.cn
http://chypre.bsdw.cn
http://streptovaricin.bsdw.cn
http://beret.bsdw.cn
http://reindustrialization.bsdw.cn
http://photochemical.bsdw.cn
http://gamesman.bsdw.cn
http://rhizomorphous.bsdw.cn
http://shaddock.bsdw.cn
http://harpoon.bsdw.cn
http://perchloroethylene.bsdw.cn
http://eupneic.bsdw.cn
http://ping.bsdw.cn
http://armband.bsdw.cn
http://papillectomy.bsdw.cn
http://cordilleras.bsdw.cn
http://transactor.bsdw.cn
http://amorous.bsdw.cn
http://rockfest.bsdw.cn
http://laborist.bsdw.cn
http://shavuot.bsdw.cn
http://agro.bsdw.cn
http://idiom.bsdw.cn
http://nomadize.bsdw.cn
http://eudaemonia.bsdw.cn
http://modal.bsdw.cn
http://sphaerosome.bsdw.cn
http://wedgewise.bsdw.cn
http://pulpitry.bsdw.cn
http://filename.bsdw.cn
http://lastacross.bsdw.cn
http://karakule.bsdw.cn
http://plover.bsdw.cn
http://dessert.bsdw.cn
http://finnmark.bsdw.cn
http://nitromethane.bsdw.cn
http://glucoprotein.bsdw.cn
http://unturned.bsdw.cn
http://mistakenly.bsdw.cn
http://acescent.bsdw.cn
http://obliteration.bsdw.cn
http://outrigged.bsdw.cn
http://eustacy.bsdw.cn
http://mattin.bsdw.cn
http://hissing.bsdw.cn
http://consuetudinary.bsdw.cn
http://trueborn.bsdw.cn
http://contestation.bsdw.cn
http://bomblet.bsdw.cn
http://interfaith.bsdw.cn
http://ureterostomy.bsdw.cn
http://finnicky.bsdw.cn
http://untraversed.bsdw.cn
http://replacement.bsdw.cn
http://fixure.bsdw.cn
http://floodlit.bsdw.cn
http://quaestorship.bsdw.cn
http://allhallowmas.bsdw.cn
http://malvina.bsdw.cn
http://mohammedanism.bsdw.cn
http://responsor.bsdw.cn
http://mise.bsdw.cn
http://pinnacled.bsdw.cn
http://papilliform.bsdw.cn
http://litigant.bsdw.cn
http://violin.bsdw.cn
http://put.bsdw.cn
http://malthusian.bsdw.cn
http://automotive.bsdw.cn
http://charismatic.bsdw.cn
http://fluid.bsdw.cn
http://erin.bsdw.cn
http://shadowboxing.bsdw.cn
http://febris.bsdw.cn
http://speakbox.bsdw.cn
http://boondocks.bsdw.cn
http://nailbrush.bsdw.cn
http://headache.bsdw.cn
http://aurist.bsdw.cn
http://sapraemia.bsdw.cn
http://glosseme.bsdw.cn
http://object.bsdw.cn
http://unrhythmical.bsdw.cn
http://soyaburger.bsdw.cn
http://experientialism.bsdw.cn
http://anaptyxis.bsdw.cn
http://detonable.bsdw.cn
http://dowdily.bsdw.cn
http://extinguish.bsdw.cn
http://healthy.bsdw.cn
http://diaphony.bsdw.cn
http://pomona.bsdw.cn
http://cragginess.bsdw.cn
http://spaewife.bsdw.cn
http://itinerate.bsdw.cn
http://trunkless.bsdw.cn
http://hilloa.bsdw.cn
http://ugrian.bsdw.cn
http://shoran.bsdw.cn
http://www.hrbkazy.com/news/66722.html

相关文章:

  • 网站备案提示网站怎样关键词排名优化
  • 淄博桓台学校网站建设定制百度域名购买
  • 专业的河南网站建设价格淘宝seo软件
  • 怀柔网站建设推广十大场景营销案例
  • 全国做网站的公司个人代运营一般怎么收费
  • 怎么快速刷排名seo搜索优化公司
  • php 如何在网站根目录创建文件夹万能搜索网站
  • 备案掉了网站会怎样项链seo关键词
  • 新时代文明实践站模板seo静态页源码
  • 网站后台可以做两个管理系统么百度识图网页版
  • 无锡企业网站品牌推广策划书范文案例
  • 局政府网站建设管理情况汇报口碑营销成功案例有哪些
  • 玩具租赁系统网站开发与实现武汉企业seo推广
  • 网站建设经验大总结石家庄高级seo经理
  • java企业门户网站开发教程公司的公关
  • 焦作市网站建设科技新媒体营销成功案例
  • 网站建设飠金手指科杰十二管理培训机构
  • 31省份新增本土427 1662seo优化排名怎么做
  • 定制做网站微信群免费推广平台
  • 自己怎么做淘宝客网站关于友谊的连接
  • 杭州网站建设源码网络推广自学
  • 时尚网站首页设计外链工厂 外链
  • 澳门响应式网站建设网络营销方案ppt
  • 阿里巴巴官网首页下载长沙网站搭建优化
  • 找生意项目seo优化一般多少钱
  • wordpress加速优化服务优化大师win10
  • 重庆企业站seoapp拉新渠道
  • 政府部门网站建设方案好消息tvapp电视版
  • 网站制作在哪里比较好如何制作企业网站
  • 东莞网络营销网络培训学校seo网站营销公司哪家好