
SpringBoot
热爱技术的小陈
于上市互联网企业工作十来年,从程序员到技术总监,从.net到php到java再到大数据,喜欢研究新技术
展开
-
如何在springboot中构建定时任务
如何在springboot中构建定时任务Spring Scheduling Tasks官网手册 https://spring.io/guides/gs/scheduling-tasks/Cron表达式https://blog.youkuaiyun.com/weixin_44371237/article/details/122382179启动类加@EnableScheduling开启定时功能@EnableScheduling //开启定时功能public class SpringbootApplicatio原创 2022-01-08 17:12:14 · 390 阅读 · 0 评论 -
hytrix默认超时时间,hytrix如何全局配置超时时间
hytrix默认超时1秒,如下源码处原创 2021-08-27 11:33:14 · 175 阅读 · 0 评论 -
@RequestParam()和@PathVariable()的区别
@RequestParam与@PathVariable为spring的注解,都可以用于在Controller层接收前端传递的数据,不过两者的应用场景不同。@PathVariable主要用于接收http://host:port/path/{参数值}数据。@RequestParam主要用于接收http://host:port/path?参数名=参数值数据,这里后面也可以不跟参数值。@RequestParam和@PathVariable这两者之间区别不大,主要是请求的URL不一样用@RequestParam原创 2021-08-17 15:08:42 · 248 阅读 · 0 评论 -
MultiValueMap与Map区别,restTemplate参数应采用MultiValueMap
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();params.add("page", page);params.add("keyword", keyword);logger.info(params);输出{page=[1], keyword=[关键字]}Map<String, String> params = new LinkedHashMap<>();para原创 2021-08-11 15:05:36 · 3366 阅读 · 1 评论 -
maven scope与optional作用
<scope>runtime</scope> 以上scope设置,说明仅适用运行和测试环节,在编译环境下不会被使用<optional>true</optional> 以上optional设置,说明项目之间依赖不传递,子项目不引用此jar包...原创 2021-08-10 09:51:23 · 287 阅读 · 0 评论 -
spring-boot-dependencies作用是统一管理各类spring-boot-starter的版本号
在pom.xml里添加<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.4.RELEASE</version></parent>这个时候再导入我们需要的springboot starter时,就可以忽略原创 2021-08-10 09:43:29 · 2432 阅读 · 0 评论 -
SpringBoot整合UEditor
https://blog.youkuaiyun.com/qq_33745799/article/details/70031641原创 2021-07-19 18:04:14 · 276 阅读 · 0 评论 -
springboot Thymeleaf整合UEditor
1.下载UEditor下载地址 https://github.com/fex-team/ueditor/releases ,将最新版本1.4.3.3的完整源码和Jsp版本UTF-8版本下载下来并解压。2.配置pom.xml项目中配置UEditor的源码需要的jar包<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>原创 2021-06-28 16:46:35 · 426 阅读 · 0 评论 -
thymeleaf 公共模板传参
公共模板<th:block id="editBottom"> <div th:text="${link}"></div></th:block>引入页面<th:block th:include="/manage/column/common::#editBottom(link='role')"></th:block>原创 2021-05-27 11:23:40 · 430 阅读 · 0 评论 -
thymeleaf绑定后端静态方法
thymeleaf<span th:text="${T(com.sanwu.help.StringHelper).test()}"></span>后端代码public class StringHelper { public static String test(){ return "test"; }}原创 2021-05-14 14:17:55 · 336 阅读 · 0 评论 -
springboot service 用 @Autowired注入 mapper 为null
Service类@Controllerpublic class AdminRoleService { @Autowired AdminRoleMapper adminRoleMapper; public AdminRole selectByPrimaryKey(Integer roleId) { AdminRole adminRole = adminRoleMapper.selectByPrimaryKey(10001); return admi原创 2021-05-12 10:45:00 · 6089 阅读 · 3 评论 -
解决‘parent.relativePath‘ of POM xxx points at instead of please verify your project structure
在如下位置加入<relativePath/>原创 2021-02-19 17:24:28 · 15255 阅读 · 3 评论 -
解决redis \xac\xed\x00\x05t\x00\x04 自定义RedisTemplate
通过自定义RedisTemplate解决package com.springboot.config;import com.fasterxml.jackson.annotation.JsonAutoDetect;import com.fasterxml.jackson.annotation.PropertyAccessor;import com.fasterxml.jackson.databind.ObjectMapper;import org.springframework.context.an原创 2021-02-07 15:31:00 · 1454 阅读 · 0 评论 -
jedis与letture区别
区别:Jedis在实现上是直接连接的redis server,如果在多线程环境下是非线程安全的,这个时候只有使用jedis pool连接池,为每个Jedis实例增加物理连接。类似BIO模式Lettuce的连接是基于Netty的,连接实例(StatefulRedisConnection)可以在多个线程间并发访问,应为StatefulRedisConnection是线程安全的,所以一个连接实例(StatefulRedisConnection)就可以满足多线程环境下的并发访问,当然这个也是可伸缩的设计,一个原创 2021-02-07 09:54:14 · 852 阅读 · 0 评论 -
swagger无法访问UI页面No mapping for GET /swagger-ui.html
检查项目是否用实现WebMvcConfigurer相关接口如下,发现WebMvcConfig.java类实现了WebMvcConfigurer接口,导致访问不了,注释即可//@Configuration//@EnableWebMvc //全面接管//public class WebMvcConfig implements WebMvcConfigurer {// @Override// public void addViewControllers(ViewControllerRegi原创 2021-02-05 14:18:30 · 1769 阅读 · 1 评论 -
Shiro整合springboot代码
package com.springboot.config;import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;import org.apache.shiro.spring.web.ShiroFilterFactoryBean;import org.apache.shiro.web.mgt.DefaultWebSecurityManager;import org.springframework.beans.factory.annotation原创 2021-02-05 13:24:47 · 172 阅读 · 0 评论 -
spring security基础配置以及放行druid代码
package com.springboot.config;import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security原创 2021-02-03 19:51:10 · 965 阅读 · 1 评论 -
sec:authorize无法生效
sec:authorize无法生效原因是springsecurity4支持2.0.9以下的springboot,高版本需要改成springsecurity5<dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity5</artifactId></depende原创 2021-02-03 19:06:53 · 899 阅读 · 2 评论 -
spring-security 官网示例地址
进官网 https://spring.io/12345原创 2021-02-03 13:58:00 · 3847 阅读 · 0 评论 -
springboot自动配置原理
启动器 spring-boot-starter<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency>spring-boot-starter-web:帮我们导入了web模块正常运行所依赖的组件spring-boot-starter-x原创 2021-02-02 11:20:13 · 142 阅读 · 0 评论 -
DruidDataSource配置属性列表
DruidDataSource配置兼容DBCP,但个别配置的语意有所区别。配置 缺省值 说明 name 配置这个属性的意义在于,如果存在多个数据源,监控的时候可以通过名字来区分开来。如果没有配置,将会生成一个名字,格式是:"DataSource-" + System.identityHashCode(this). 另外配置此属性至少在1.0.5版本中是不起作用的,强行设置name会出错。详情-点此处。 url 连接数据库的url,不同数据库不一样。例如..原创 2021-02-01 18:34:39 · 371 阅读 · 0 评论 -
druid配置
spring: datasource: username: root password: 123456 #?serverTimezone=UTC解决时区的报错 url: jdbc:mysql://localhost:3306/springboot?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8 driver-class-name: com.mysql.cj.jdbc.Driver原创 2021-02-01 18:10:41 · 258 阅读 · 0 评论 -
springboot配置文件用.yaml还是.yml
原文https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config如原文,.properties, .yaml, and .yml都可以原创 2021-01-29 16:35:40 · 1975 阅读 · 0 评论 -
springboot多环境配置与yaml的多文档块
多环境配置例如:application-test.properties 代表测试环境配置application-dev.properties 代表开发环境配置但是Springboot并不会直接启动这些配置文件,它默认使用application.properties主配置文件;我们需要通过一个配置来选择需要激活的环境:spring.profiles.active=devyaml多文档块server: port: 8081#选择要激活那个环境块spring: profiles:原创 2021-01-29 12:47:40 · 545 阅读 · 0 评论 -
springboot 自动配置原理,源码解析
springboot 自动配置都在以下包里原创 2021-01-29 10:18:58 · 223 阅读 · 0 评论 -
dependencies与dependencyManagement的区别
dependencies子项目不用声明即可导入(子项目自动继承父项目依赖,并导入,不用另外声明)dependencyManagement子项目需要声明才能导入(只声明依赖,不实现引入,子项目需要显示声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom;另外如果子项目中指定了版本号,那么会使用子项目中指定的jar版本。)...原创 2021-01-28 10:40:32 · 194 阅读 · 0 评论 -
springboot maven依赖为什么不用写版本
查看porm.xml父工程spring-boot-starter-parent,再查看他的父工程spring-boot-dependencies原创 2021-01-28 10:06:47 · 786 阅读 · 0 评论 -
springboot访问不到静态资源
springboot访问不到静态资源,查看如下生成classes中是否有文件如果没有,则clean一下,再编译原创 2021-01-27 15:03:41 · 399 阅读 · 1 评论 -
@RequestMapping和@GetMapping 注解区别
@RequestMapping和@GetMapping区别@RequestMapping可以指定GET、POST请求方式@GetMapping相当于@RequestMapping的GET请求方式原创 2021-01-27 14:08:56 · 860 阅读 · 0 评论 -
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
maven 配置 jpa 又没配置数据库,引起的错误如下注释掉即可原创 2021-01-27 11:27:35 · 166 阅读 · 0 评论