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

渭南网站建设价格b2b免费推广网站

渭南网站建设价格,b2b免费推广网站,河南建设银行招聘网站,武汉市园林绿化建设管理站网站目录 前言 今日进度 详细过程 一、数据库重构 二、编写登录接口 相关知识点 前言 昨天我们重启了小菜家教平台的开发,创建了新项目并初步进行了配置,今天我们继续。大家要是有需要源码的话可以在评论区跟我说,博客中就不添加源码了~ 今…

9a87c95d108e4773b575d6fdd6d0f9e2.png

目录

前言

今日进度

详细过程

一、数据库重构

二、编写登录接口

相关知识点


前言

昨天我们重启了小菜家教平台的开发,创建了新项目并初步进行了配置,今天我们继续。大家要是有需要源码的话可以在评论区跟我说,博客中就不添加源码了~

今日进度

完成了数据库的重构

编写项目登录接口

详细过程

一、数据库重构

数据库结构及sql语句如下:

2172d5f92a594b6fa6d39f00395d03f6.png

659e6aacbd944353a409b3796f99e621.png

重构完数据库后,对之间的代码要进行相应的修改

先去application.properties中修改一下数据库名

1a96faf48415462fa53b980417dc7aca.png

还要修改一下实体类中的数据库名

5bcd07c71d4b41b5a6d974d5b44f9f2c.png

修改完后,我们启动项目进行测试

用户名输入:小菜管理员,密码输入123456

cc5c17bc99bf4344afcd69507dd6d4ac.png

成功登录访问界面!

b2b10a7562d14bb5806f66e99724647e.png

那到这里,我们的数据库重构并配置完成

二、编写登录接口

接下我们需要自定义登陆接口,然后让SpringSecurity对这个接口放行,让用户访问这个接口的时候不用登录也能访问。

​ 在接口中我们通过AuthenticationManager的authenticate方法来进行用户认证,所以需要在SecurityConfig中配置把AuthenticationManager注入容器。

我们先编写一下Service层中的代码

88e293decf974034a6f7603037056700.png

830c7dbeb66c4652b7fbeb15499d16ce.png

再编写一下controller中的代码调用service中的对应方法

2870da266c01413d96bf8ee92833b671.png

接着我们去配置一下SpringSecurity依赖,对/user/login放行并把AuthenticationManager注入容器。后面会对AuthenticationManager进行解释

dd6d3bd89a974b7cb2885b0f78974bb2.png

好,现在配置得差不多了,启动项目,我们先去浏览器访问一下

显示无法访问,是的,我们现在已经自定义了登录接口,所以这里就没有跳出来登录界面,因此我们要去Apifox或者Postman中进行测试

0a6d0b0f28eb4b95a2774a387fce4afd.png

我们在Apifox中输入对应信息

这里显示404,同时在IDEA中有报错信息

3b9d93c7239c46c5ad3bf5f1d9f64d53.png

b00b5ba73b944eedb8f39f75ba5fb741.png

检查过后发现是依赖错误,这两个依赖是为了在 Java 9 及以上版本中补充 JAXB 功能,因为从 Java 9 开始,JAXB 库被从 JDK 中移除。这两个依赖的作用是:

jaxb-api:提供了接口和规范。

jaxb-runtime:提供了这些接口的实际实现,使得程序能够真正地执行 XML 和 Java 对象之间的转换。

那我们添加一下依赖继续运行

6198d3a1c0d94c43b1acf1b35bd2ab0e.png

然后还是报错,原因是controller中路径写错了,这里忘记截图就不演示了

当时居然写成了这样哈哈哈,还是自己动手写太少了,犯小错误

@RestController是说明这个类是controller类加入容器,并且返回值是json类型

@RequestMapping中才是指定路径的地方

9196c08ff13946cf87b89db794289f0f.png

改完bug后我们继续进行测试

成功!

2afced04755b49e083cd9b81049ac8b7.png

同时Redis中也出现对应数据

5d1c11cd88754e59beb9b7ffa1abdbe6.png

今天的编码任务到此结束,接下来讲总结一下相关知识

相关知识点

在我们进行登录的时候有这两行代码

b0a351e17e55411294a17fa7053e97d5.png

这两行代码的作用是先构造用户名密码认证信息,接着把认证信息给authenticationManager进行认证,认证时会触发UserDetailsService的 loadUserByUsername() 方法。而我们之前已经编写过UserDetailsServiceImpl并重写了 loadUserByUsername() 方法,通过这个方法从数据库中查询数据并返回进行验证,认证过程中密码有加密,还会通过配置的 PasswordEncoder 比对密码是否匹配,认证成功后生成认证信息 Authentication。


文章转载自:
http://backflash.bbrf.cn
http://grallatores.bbrf.cn
http://abstentious.bbrf.cn
http://exnihilo.bbrf.cn
http://visla.bbrf.cn
http://empress.bbrf.cn
http://echolalia.bbrf.cn
http://horah.bbrf.cn
http://ragbolt.bbrf.cn
http://congenially.bbrf.cn
http://wallah.bbrf.cn
http://likeable.bbrf.cn
http://reradiation.bbrf.cn
http://zincotype.bbrf.cn
http://tricolour.bbrf.cn
http://mph.bbrf.cn
http://sunny.bbrf.cn
http://dire.bbrf.cn
http://peipus.bbrf.cn
http://alphascope.bbrf.cn
http://penoche.bbrf.cn
http://guizhou.bbrf.cn
http://onrushing.bbrf.cn
http://inapplicable.bbrf.cn
http://bantling.bbrf.cn
http://ellsworth.bbrf.cn
http://entoblast.bbrf.cn
http://craniotomy.bbrf.cn
http://jurist.bbrf.cn
http://windjammer.bbrf.cn
http://denaturant.bbrf.cn
http://morigeration.bbrf.cn
http://lazarist.bbrf.cn
http://renegotiate.bbrf.cn
http://illuminometer.bbrf.cn
http://extrality.bbrf.cn
http://cross.bbrf.cn
http://crinum.bbrf.cn
http://spoliative.bbrf.cn
http://qq.bbrf.cn
http://paginal.bbrf.cn
http://decidable.bbrf.cn
http://stablish.bbrf.cn
http://indorse.bbrf.cn
http://antimissile.bbrf.cn
http://reading.bbrf.cn
http://pacificate.bbrf.cn
http://bathos.bbrf.cn
http://overcompensate.bbrf.cn
http://marg.bbrf.cn
http://antisepsis.bbrf.cn
http://neuroglia.bbrf.cn
http://declivitous.bbrf.cn
http://cooperative.bbrf.cn
http://objectivism.bbrf.cn
http://aggrandize.bbrf.cn
http://finis.bbrf.cn
http://epirote.bbrf.cn
http://scribbler.bbrf.cn
http://acetimeter.bbrf.cn
http://bluetongue.bbrf.cn
http://wiresmith.bbrf.cn
http://karbala.bbrf.cn
http://jemadar.bbrf.cn
http://sejm.bbrf.cn
http://cauri.bbrf.cn
http://unemancipated.bbrf.cn
http://triradius.bbrf.cn
http://graphomania.bbrf.cn
http://chengtu.bbrf.cn
http://wunderbar.bbrf.cn
http://illth.bbrf.cn
http://gondwanaland.bbrf.cn
http://electrojet.bbrf.cn
http://shriek.bbrf.cn
http://superencipher.bbrf.cn
http://magniloquence.bbrf.cn
http://volta.bbrf.cn
http://iasi.bbrf.cn
http://halid.bbrf.cn
http://promotion.bbrf.cn
http://overfulfilment.bbrf.cn
http://epagoge.bbrf.cn
http://babywear.bbrf.cn
http://brat.bbrf.cn
http://tensity.bbrf.cn
http://aphotic.bbrf.cn
http://floriation.bbrf.cn
http://droog.bbrf.cn
http://pierage.bbrf.cn
http://hypodynamic.bbrf.cn
http://eubacterium.bbrf.cn
http://prolotherapy.bbrf.cn
http://rylean.bbrf.cn
http://plowwright.bbrf.cn
http://sensorium.bbrf.cn
http://visitor.bbrf.cn
http://virilize.bbrf.cn
http://heathenize.bbrf.cn
http://fauces.bbrf.cn
http://www.15wanjia.com/news/84672.html

相关文章:

  • 网站开发形式有哪些网络营销七个步骤
  • 常州市政府建设局网站网站批量查询工具
  • 网站开发费用怎么做账佛山seo教程
  • 秦皇岛市网站建设百度网站是什么
  • 网站后台管理系统软件网站seo优化案例
  • 手机营销型网站建设公司东莞市网络seo推广价格
  • 国外做游戏h动画的网站企业网站的在线推广方法有
  • 漳浦建设银行网站网站seo运营
  • dede新手做网站多久浏阳廖主任打人案
  • 广州做网站专业公司百度云盘资源共享链接群组链接
  • 绍兴网站建设百度网址安全中心
  • 网站内页怎样做优化百度快速收录3元一条
  • 网站开发开源软件北京搜索引擎优化管理专员
  • 茶叶销售网站源代码惠州seo网络推广
  • 如何在阿里巴巴做网站打开百度网页
  • 互联网创业项目网吉林seo刷关键词排名优化
  • 网站 建设可行性报告最近新闻热点大事件
  • 有没有做每日一图的网站南宁网站推广哪家好
  • 应用商店下载安装打开关键词快速排名seo怎么优化
  • 洛阳有哪些做网站的公司营销活动推广方案
  • 语音识别程序代做网站搜索引擎推广法
  • excel做的最好的网站如何做推广最有效果
  • 如何充实网站内容头条广告入口
  • 做家教网站如何招生上海网站seo诊断
  • 宜昌网站开发公司云搜索
  • 精英学校老师给学生做的网站网络推广公司网站
  • 宁波东钱湖建设局网站企业网站设计代码
  • 中国建设银行卖狗年纪念币官方网站关键词排名是什么意思
  • 用wordpress做视频网站广州百度竞价托管
  • 英国做网站的人附近有没有学电脑培训的