
SpringBoot
:)#
自有中正之道,不亢不卑,不骄不诌,何得如此也!
展开
-
【SpringBoot文件上传】
Controller@Slf4j@Controllerpublic class FormController { //th:href="@{/upload} @GetMapping("upload") public String form(){ return "form/upload"; } //th:action="@{/upload} @PostMapping("upload") public String upload(@Requ原创 2022-05-09 20:06:29 · 310 阅读 · 0 评论 -
【SpringBoot拦截器】
LoginIntercepter@Slf4jpublic class LoginIntercepter implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String requestURI = reques原创 2022-05-09 15:25:28 · 225 阅读 · 0 评论 -
【SpringBoot内容协商】
基于请求头的内容协商Accept:Application/xmlacceptableTypesproducibleTypesmediaTypesToUse for (MediaType requestedType : acceptableTypes) { for (MediaType producibleType : producibleTypes) { if (requestedType.isCompatibleWith(producibleType)) {原创 2022-05-08 22:25:49 · 395 阅读 · 0 评论 -
【SpringBoot重写配置的方法】
文章目录不用@EnableWebMvc注解,使用 @Configuration + WebMvcConfigurer 自定义规则方法一:实现WebMvcConfigurer接口方法二:容器中放一个WebMvcConfigurer重写addFormatters配置函数新版默认为false不用@EnableWebMvc注解,使用 @Configuration + WebMvcConfigurer 自定义规则自定义一个配置类实现接口WebMvcConfigurerjdk8有接口的默认实现,我们只需要重写我原创 2022-05-07 22:20:53 · 2486 阅读 · 0 评论 -
【SpringBoot基本注解】
文章目录@RequestAttribute(获取请求域属性)@PathVariable(获取url中的变量)@RequestHeader(获取请求头)@RequestParam(获取请求变量)@CookieValue(获取cookie)@RequestBody(获取请求体)@MatrixVariable@RequestAttribute(获取请求域属性)@PathVariable(获取url中的变量)@RequestHeader(获取请求头)可以使用Map获取请求头中的所有键值对@Request原创 2022-05-07 21:31:24 · 354 阅读 · 0 评论 -
【自定义配置类覆盖xxxAutoConfiguration】
自定义xxxConfig类并实现WebMvcConfiger,就会使WebMvcAutoConfiguration配置类失效,因为在该类中有@ConditionalOnMissingBean(WebMvcConfigurationSupport.class),这个注解会触发 ,这是因为我们在自定义的xxxConfig类中实现了WebMvcConfiger,点进这个接口就可以知道它继承了WebMvcConfigurationSupport,所以springboot自动帮我们配置好的webMvcAutoConf原创 2022-05-06 00:36:18 · 502 阅读 · 0 评论 -
【SpringBoot配置提示】
IDEA自定义的类和配置文件绑定一般没有提示,我们只需引入依赖,从此自定义类配置也有提示。<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional></depende原创 2022-05-05 22:43:24 · 411 阅读 · 0 评论 -
【SpringBoot自动配置源码分析】
文章目录分析源码快捷键@SpringBootApplication1.@SpringBootConfiguration2.@ComponentScan3. @EnableAutoConfiguration1.@AutoConfigurationPackage自动配置自己的包2.@Import总结:分析源码快捷键选中需要检索的关键词Ctrl+N@SpringBootApplication等于三个注解合体@SpringBootConfiguration@EnableAutoConfigurati原创 2022-05-05 17:35:49 · 306 阅读 · 0 评论 -
【SpringBoot底层注解】
文章目录底层注解@Configuration向容器中注册组件的方法1.包扫描(SpringBoot默认扫描包)+注解方式(**@Component、@Controller、@Service、@Repository**)2.@Bean导入第三方包3.@Import方法@Conditional条件装配@ImportResource导入原生配置文件@ConfigurationProperties1.@Component+@ConfigurationProperties2.@EnableConfigurationP原创 2022-05-05 15:53:24 · 460 阅读 · 0 评论 -
【springboot整合mybatis】
项目架构pojo:实体类层,封装的是数据中的设计的表对应的元素,及其相关函数。dao/mapper:Mapper的接口(如查询所有User/插入User等)以及Mapper.xml文件,实现sql操作。Service:服务实现层,调用dao/mapper层方法进行实现,如果项目不需要处理逻辑,service和dao层一样。Controller:控制层,调用一个个Service层的实现方法完成一个个具体功能/返回给前端。准备工作创建数据库drop table if exists departme原创 2022-05-04 13:41:52 · 572 阅读 · 0 评论 -
【SpringBoot+JDBC对数据库CRUD】
文章目录连接配置数据库编写controller测试文件启动主类前端调用接口,查询数据库成功连接配置数据库导入依赖 <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>原创 2022-05-04 05:28:12 · 990 阅读 · 0 评论 -
【springboot项目解决Whitelabel Error Page问题图解】
解决方法:将启动类提到外面分析原因:SpringBoot项目的Bean装配默认规则是根据Application类所在的包位置从上往下扫描。当然你也可以把代码放在某个包里面,不放在最外层,这样需要搭配@ComponentScans注解来设定要扫描的包路径...原创 2022-05-03 14:38:30 · 803 阅读 · 0 评论 -
【springboot项目添加ico方法】
将图片重命名为favicon.ico放入资源目录下的static文件夹,在首页引入<link rel="icon" href="favicon.ico">Ctrl+F5刷新页面即可生效原创 2022-05-03 10:17:05 · 724 阅读 · 0 评论 -
【SpringBoot分析源码常用快捷键】
文章目录Ctrl+F12(显示当前类的函数)Ctrl+f 搜索Ctrl+n全局搜索Ctrl+h打开函数继承树双击shift:搜索源码函数Ctrl+Shift+(+/-)收放函数Ctrl+F12(显示当前类的函数)Ctrl+f 搜索Ctrl+n全局搜索Ctrl+h打开函数继承树双击shift:搜索源码函数Ctrl+Shift+(+/-)收放函数 public void addResourceHandlers(ResourceHandlerRegistry registry) {原创 2022-05-03 10:00:02 · 689 阅读 · 0 评论