
spring boot
文章平均质量分 79
就这烊了
这个作者很懒,什么都没留下…
展开
-
springboot的拦截器
1、 自定义类加注解@Configuration并实现WebMvcConfigurer接口类,重写addInterceptors(){}@Configurationpublic class MyConfiger implements WebMvcConfigurer { @Autowired private LoginInterceptor loginInterceptor; /** * 添加拦截 和放行的路径 * @param registry原创 2020-09-03 10:04:50 · 120 阅读 · 0 评论 -
springboot中模板引擎介绍thymeleaf、Freemaker
首先官方不推荐使用jsp(本质是servlet,它是后端渲染,需要JVM支持,消耗性能)1、Freemarker Template Lanaguage (FTL) 文件后缀是.ftl特点:严格依赖MVC模式,不依赖Servlet容器。不消耗性能2、Thymeleaf(springboot 主推)特点:轻量级模板引擎,页面有复杂业务,不推荐使用。比如页面有很多个判断(会导致解析DOM或者XML占用过多内存)。可以直接在浏览器打开。3、整合freemarker 1、Freemarker相关mav原创 2020-09-03 10:04:12 · 386 阅读 · 0 评论 -
springboot之启动原理解析及源码阅读
转载自:https://www.cnblogs.com/shamo89/p/8184960.html前言SpringBoot为我们做的自动配置,确实方便快捷,但是对于新手来说,如果不大懂SpringBoot内部启动原理,以后难免会吃亏。所以这次博主就跟你们一起一步步揭开SpringBoot的神秘面纱,让它不在神秘。正文我们开发任何一个Spring Boot项目,都会用到如下的启动类@SpringBootApplicationpublic class Application { publ转载 2020-09-03 10:05:04 · 193 阅读 · 0 评论 -
7、配置全局异常_自定义异常返回自定义页面或返回json数据
全局异常处理1.全局异常处理类/** * 全局异常处理类 (作用: 怎么去使用异常类 ,使用异常类要做什么事) */@RestControllerAdvicepublic class MyExceptionHandler { /** @ExceptionHandler 表示 异常拦截后 ,要执行什么功能 , Exception.class 代表可以处理所以异常 * * @param e 可以获取到异常内部一些信息 * @param reque原创 2020-09-03 10:05:13 · 403 阅读 · 0 评论 -
springboot的单元测试_个性化启动Banner设置
springboot的单元测试1.引入单元测试依赖<!--单元测试--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope>原创 2020-09-02 16:13:49 · 176 阅读 · 0 评论 -
springboot通过注解读取配置文件并映射到属性或实体类中
通过注解读取配置application.perperties文件中的 key-value(键值对)并将key-value中的value映射到属性或实体类中1、application.perperties# 这里是 linux一些配置信息 ,需要读取到 java程序 (自定义的key)server.name= centos7server.ip=192.168.11.1212、给属性增加注解读取配置文件数据@Component //交给spring管理,不需要new对象@PropertySo原创 2020-09-02 16:08:03 · 856 阅读 · 0 评论 -
springboot热部署配置_自动_手动
自动热部署1.引入依赖<!--引入热部署依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope>原创 2020-09-02 15:57:36 · 227 阅读 · 0 评论 -
Springboot文件上传示例
可以指定上传到当前工程 ,也可以指定上传到其他 目录upload.html<!DOCTYPE html><html> <head> <title>uploadimg.html</title> <meta name="keywords" content="keyword1,keyword2,keyword3"></meta> <meta http-equiv="Content-Type" c原创 2020-09-02 15:33:58 · 127 阅读 · 0 评论 -
SpringBoot简介及与SpringMVC的区别
Spring Boot简介springboot和springmvc的区别原创 2020-09-02 14:18:47 · 118 阅读 · 0 评论 -
springboot_启动白屏页面_HTTP请求注解_ postman界面介绍
springboot启动白屏页面解决方案1.将Springboot1Application直接放在主包名com.hp下2.给Springboot1Application加注解@ComponentScan(basePackages = “cn.hp”)SpringBoot2.xHTTP请求注解讲解和简化注解配置技巧1、@RestController and @RequestMapping是springMVC的注解,不是 springboot特有的 2、@RestController = @Contr原创 2020-09-02 13:41:19 · 576 阅读 · 0 评论 -
http接口get/post/put/delete请求测试
http接口get请求方式// TODO 返回值为json数据@RestControllerpublic class TwoHttpController { private Map<String, Object> map = new HashMap<>(); /** * 1.获取用户信息 ,restful风格 * * @return */ @RequestMapping(value = "/v1/{city_id}原创 2020-09-02 13:40:24 · 1559 阅读 · 0 评论 -
json框架介绍和Jackson返回结果处理
1、常用框架阿里fastjson,谷歌gson等JavaBean序列化为Json,性能:Jackson > FastJson > Gson > Json-lib同个结构Jackson、Fastson、Gson类库各有优点,各有自己的专长空间换时间,时间换空间2、 jackson相关注解 (作用于实体类属性)指定字段不返回 @JsonIgnore格式化日期 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "zh原创 2020-09-02 13:39:49 · 158 阅读 · 0 评论 -
Springboot静态文件的访问
1.static 下面的静态文件访问方式位于static下的静态文件可以直接访问static/img/xx.pngstatic/js/xx.js访问方式: localhost:8080/img/xx.png localhost:8080/js/xx.js2.其他静态目录resources目录中除了static这个静态文件外,还有 resources和 public这2个目录, 三者优先级resources > static > public3.t原创 2020-09-02 11:12:16 · 886 阅读 · 0 评论 -
SpringBoot_工程搭建_打包、启动jar包和war包
工程搭建打包、启动jar包4.win+r cmd 进入命令符窗口打包、启动war包原创 2020-09-02 09:08:39 · 550 阅读 · 1 评论