
SpringBoot
文章平均质量分 53
学习笔记
我怎么什么都不会啊
这个人很懒
展开
-
SpringBoot之前后端分离跨域问题
在前后端分离的项目中可能存在前端项目的访问端口和后端项目不一致的情况, 这个时候需要我们修改端口为一致的在前后端分离的项目中, 前端项目因为测试的需要会有自己的内部数据数据用于测试验证方案的可行性, 但如果将前后端结合时, 我们的数据都来源于后端, 所以这个时候我们需要将前端自己内部的mock去除, 从而配合后端解决跨域问题在前后端分离的项目中即使前后端端口一致, 也不能解决跨域的问题, 还需要在后端中进行配置配置需要跨域的地址配置跨域的请求头配置跨域的请求方法配置跨域请求是否可以携带..原创 2021-06-20 17:23:06 · 367 阅读 · 0 评论 -
SpringBoot之mybatis配置版
SpringBoot之mybatis配置版1.导入pom依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.0</version> .原创 2021-06-13 17:18:13 · 865 阅读 · 0 评论 -
SpringBoot之注解版mybatis
SpringBoot之注解版mybatis1.导入pom依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.0</version> .原创 2021-06-13 17:17:27 · 217 阅读 · 0 评论 -
SpringBoot之整合Druid数据源
SpringBoot之整合Druid数据源1.导入Druid数据源pom依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.23</version> </dependency>.原创 2021-06-13 00:12:46 · 251 阅读 · 1 评论 -
SpringBoot之使用外部servlet容器
SpringBoot之使用外部servlet容器嵌入式Servlet容器:应用打成可执行的jar 优点:简单、便携; 缺点:默认不支持JSP、优化定制比较复杂(使用定制器【ServerProperties、自定义EmbeddedServletContainerCustomizer】,自己编写嵌入式Servlet容器的创建工厂【EmbeddedServletContainerFactory】);外置的Servlet容器:外面安装Tomcat—应用war包的方式打包;步骤1)、必须创建一个.原创 2021-06-11 20:25:52 · 257 阅读 · 0 评论 -
SpringBoot之注册servlet三大组件
SpringBoot之注册servlet三大组件1.Servlet自定义servlet类继承HttpServletpublic class MyServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doPost(req,res.原创 2021-06-10 18:41:14 · 150 阅读 · 0 评论 -
SpringBoot之嵌入式servlet容器配置修改
SpringBoot之嵌入式servlet容器配置修改1.在springboot配置文件中修改server: port: 9999 tomcat: uri-encoding: utf-8 servlet: context-path: /crud //通用的servlet容器设置server.xxx//tomcat的设置server.tomcat.xxx2.编写一个WebServerFactoryCustomizer ; Web 服务器工厂定制器, 来修改.原创 2021-06-10 18:40:40 · 176 阅读 · 0 评论 -
SpringBoot之错误页面
SpringBoot之错误页面错误处理机制1)、SpringBoot默认的错误处理机制默认效果: 1)、浏览器,返回一个默认的错误页面[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PoPKCwdQ-1623069001924)(D:/百度网盘下载/源码、资料、课件/文档/Spring Boot 笔记/images/搜狗截图20180226173408.png)]浏览器发送请求的请求头:[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(i.原创 2021-06-07 20:31:46 · 825 阅读 · 1 评论 -
SpringBoot之日期格式和hiddenmethod
SpringBoot之日期格式和hiddenmethod1.日期格式的转换在springboot中, 默认的日期格式使用 / 分割通过如下属性配置可以修改日期格式spring: mvc: format: date: yyyy-MM-dd2.关于请求方式转换在springboot中默认只有get和post两种请求, 但是我们可以使用隐藏请求去替换默认请求使用如下方法<input type="hidden" name="_method" value="put"&.原创 2021-06-06 18:40:08 · 609 阅读 · 0 评论 -
SpringBoot之使用thymeleaf进行页面抽取
SpringBoot之使用thymeleaf进行页面抽取1.使用th:fragment标签定义公共片段例如在类路径下的templates目录下的dashboard.html页面中, 定义一个公共片段 <nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0" th:fragment="topbar"> 这是公共片段的内容 </nav>2.使用th:replace标签引入公共片段例.原创 2021-06-05 18:43:25 · 354 阅读 · 1 评论 -
SpringBoot之拦截器
SpringBoot之拦截器1.实现自己的拦截器实现HandlerInterceptor接口, 重写preHandle方法, 返回true请求通行, 返回false请求拦截public class MyHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response,.原创 2021-06-04 23:15:11 · 263 阅读 · 0 评论 -
SpringBoot之国际化
SpringBoot之国际化1.编写国际化配置文件一般有三个文件, 分别是默认配置, 中文配置, 英文配置 例如一个登陆页面的国际化配置文件login.propertieslogin.password=密码login.remember=记住我login.tip=请登录login.username=用户名login.sign=登录login_en_US.propertieslogin.password=Passwordlogin.remember=Remember me.原创 2021-06-02 18:11:43 · 781 阅读 · 1 评论 -
SpringBoot之扩展与全面接管SpringMVC
SpringBoot之扩展与全面接管SpringMVCIf you want to keep those Spring Boot MVC customizations and make more MVC customizations (interceptors, formatters, view controllers, and other features), you can add your own @Configuration class of type WebMvcConfigurer but .原创 2021-06-01 23:15:04 · 284 阅读 · 1 评论 -
SpringBoot之Thymeleaf语法
SpringBoot之Thymeleaf语法1.导入Thymeleaf的starter<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>2.Thymeleaf属性配置@ConfigurationPropertie.原创 2021-06-01 22:12:43 · 353 阅读 · 1 评论 -
SpringBoot之webjars和静态资源映射
SpringBoot之webjars和静态资源映射1.webjars所有/webjars/**请求, 都去classpath:/META-INF/resources/webjars/下面寻找资源webjars: 以jar包的方式引入资源webjars官网: https://www.webjars.org/例如在项目中引入jQuery的webjar<dependency> <groupId>org.webjars</groupId> <.原创 2021-05-31 23:50:44 · 331 阅读 · 0 评论 -
SpringBoot之日志
SpringBoot之日志1.关于日志级别error > warn > info > debug > tracespringboot默认日志级别是 info我们可以在springboot的默认配置文件中修改日志级别logging.level是map类型, 我们可以指定不同包下使用不同的日志级别logging: level: com.atguigu: trace2.以文件形式打印日志logging.file.namespringboot默认日志的输出方.原创 2021-05-30 20:22:00 · 4804 阅读 · 2 评论 -
SpringBoot之配置文件的加载位置
SpringBoot之配置文件的加载位置springboot启动会扫描以下位置的application.properties或者application.yaml文件作为springboot的默认配置文件file:./config/ 项目目录下的config目录下file:./ 项目目录下classpath:/config/ 类路径下的config目录下classpath:/ 类路径下以上是按照优.原创 2021-05-29 14:41:06 · 267 阅读 · 0 评论 -
SpringBoot之Profile多环境支持
SpringBoot之Profile多环境支持1.多profile文件我们在主配置文件编写的时候, 文件名可以是application-{profile}.properties/yaml默认使用application.properties或application.yaml当我们为不同的生产环境编写了多个配置文件时, 可以通过在默认使用的配置文件中指定 spring.profiles.active 激活使用哪个配置文件propertiesspring.profiles.active=devy.原创 2021-05-28 17:55:33 · 248 阅读 · 0 评论 -
SpringBoot之配置文件占位符
SpringBoot之配置文件占位符1.随机数${random.value}${random.int}${random.int(max)}${random.int(min,max)}${random.long}${random.long(max)}${random.long(min,max)}${random.uuid}2.占位符获取前面配置的属性值, 如果没有可以使用:指定默认值person.name=${random.uuid}person.dog.name=$.原创 2021-05-28 17:54:04 · 140 阅读 · 0 评论 -
SpringBoot之PropertySource注解ImportResource注解Bean注解
SpringBoot之PropertySource注解ImportResource注解Bean注解1.PropertySource注解当我们使用ConfigurationProperties注解时, 我们可以通过指定前缀, 将application.yml或application.properties中配置的属性注入到Java Bean中, 但是如果所有java bean的属性都写在主配置文件中, 主配置文件就会越来越大, 所以我们可以使用另一种方式, 给java bean一个单独的配置文件, 此时我.原创 2021-05-28 17:49:57 · 143 阅读 · 2 评论 -
ConfigurationProperties和Value
SpringBoot之ConfigurationProperties和Value注解的区别1.@ConfigurationProperties和@Value获取值的比较@ConfigurationProperties@Value功能批量注入配置文件中的属性一个个指定松散绑定(松散语法)支持不支持SpEL不支持支持JSR303支持不支持复杂类型封装支持不支持无论使用@ConfigurationProperties还是@Value都可.原创 2021-05-25 23:17:29 · 2903 阅读 · 1 评论 -
SpringBoot之yaml基础语法
SpringBoot之yaml基础语法1.普通值(字符串, 数字, 布尔)k : v 直接写字符串默认不用加双引号或单引号“” : 双引号, 不会转译字符串里面的特殊字符, 特殊字符会表达它本身的意思 name : “zhangsan \n lisi” 输出: zhangsan 换行 lisi‘’ : 单引号, 会转译字符串里面的特殊字符, 特殊字符会作为普通字符串表示 name : “zhangsan \n lisi” 输出: zhangsan \n lisi2.对象.原创 2021-05-25 18:58:50 · 451 阅读 · 0 评论 -
SpringBoot入门之HelloWorld
SpringBoot入门之HelloWorld1.SpringBoot官网: https://spring.io/2.第一步配置maven依赖 <!-- 继承SpringBoot启动器父依赖 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactI.原创 2021-05-24 23:30:09 · 93 阅读 · 0 评论