springboot
观棋不语的我
希望能找一份不倒贴钱的工作
展开
-
SpringBoot No converter found for return value of type: class com.example.zhishanchanquan.util.R]
根据报错得知是R这个类找不到转换器:原因:成员属性为私有,且没有相应的getter和setter,系统无法解析该类出错代码类:解决方案有两种:1、加上lombok的@Data注解,添加getter和setter2、将成员属性修饰符改成public...原创 2020-11-01 11:25:31 · 2227 阅读 · 0 评论 -
Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl 依赖版本不兼容问题
SpringBoot项目运行报错:Factory method ‘defaultValidator’ threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl查看Maven依赖,应该是jar包版本不兼容问题:将该jar报排除,重新导入低版本的jar包,运原创 2020-08-29 15:07:40 · 7888 阅读 · 1 评论 -
SpringBoot启动报错Error processing condition on org.springframework.boot.autoconfigure XXX
这种错误一般是依赖版本问题或者依赖组件缺少依赖缺少一般在排除exclude依赖的时候注意原创 2020-08-17 14:31:14 · 28057 阅读 · 0 评论 -
设置SpringBoot接收文件大小
原因:springboot内置tomact的的文件传输默认为1MB,超过1MB将报错配置文件加上:#文件上传大小为20Mspring.servlet.multipart.max-file-size=20MB#请求大小为20Mspring.servlet.multipart.max-request-size=20MB原创 2020-05-11 11:37:18 · 1288 阅读 · 2 评论 -
SpringBoot启动异常:Error creating bean with name 'defaultValid
原因是 org.hibernate.validator 版本和SpringBoot版本不匹配添加hibernate-validator依赖指定版本<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator --> <dependency> <...原创 2020-05-07 11:19:15 · 2195 阅读 · 0 评论 -
SpringBoot配置文件启动时动态配置参数方法
序言当我们要同时启用多个项目而又要使用不同端口或者变换配置属性时,我们可以在配置文件中设置${变量名}的变量来获取启动时传入的参数,从而实现了动态配置参数,使启用项目更加灵活例子server: port: ${PORT:50101} #服务端口spring: application: name: xc‐govern‐center #指定服务名eureka: clien...原创 2020-04-14 11:04:13 · 14376 阅读 · 0 评论 -
@Value获取yml格式配置文件的数据
#自定义一个RabbitMQ配置信息(每个页面都有一个客户端负责监听)xuecheng: mq: queue: queue_cms_postpage_01 #cms客户端监控的队列名称(不同的客户端监控的队列不能重复) routingKey: 5a751fab6abb5044e0d19ea1 #此routingKey为门户站点ID//队列的名称@Value("${xue...原创 2020-04-04 11:56:35 · 3172 阅读 · 0 评论 -
SpringBoot启动类模板
package com.xuecheng.manage_cms;import org.springframework.boot.SpringApplication;import org.springframework.boot.SpringBootConfiguration;import org.springframework.boot.autoconfigure.SpringBootAp...原创 2020-03-28 11:44:26 · 574 阅读 · 0 评论 -
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:166)--无限递归
异常原因:两个实体类的无限递归, 如分类中有产品属性, 产品中有分类属性,导致无限嵌套。解决方法:1、将产品中的分类属性set为NULL,终止套娃2、在产品中的分类属性上添加@JsonIgnore注解, 转换json格式时忽略该属性@JsonIgnore注解:当该实体类转换成Json时,有@JsonIgnore标注的属性将被忽略。例如将实体类传向前端时,该实体类被转换成Json格式,...原创 2020-03-04 23:16:05 · 1201 阅读 · 0 评论 -
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
初始化的时候session关闭了,这个主要是因为hibernate默认的懒加载策略:默认lazy为true 引起的异常。1、配置文件加上#lazy=falsespring.jpa.properties.hibernate.enable_lazy_load_no_trans=true2、在实体类加上@Entity@Proxy(lazy = false) ------//关闭懒加载...原创 2020-03-02 14:50:58 · 158 阅读 · 0 评论 -
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hib
package com.example.bean;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.Tabl...原创 2020-02-29 09:48:36 · 533 阅读 · 1 评论 -
分页代码
import org.springframework.data.domain.Page;import org.springframework.data.domain.PageRequest;import org.springframework.data.domain.Pageable;import org.springframework.data.domain.Sort; Sort...原创 2020-02-24 18:30:36 · 90 阅读 · 0 评论 -
springboot thymeleaf 引用静态资源时要注意的事项
静态资源放在 static 文件夹下, html 页面放在 templates 下1、当项目运行时 static文件夹和templates文件夹会合并在一起2、templates下如何引入静态资源(参考我上面的项目目录):<link th:href="@{/css/backgroud.css}" rel="stylesheet">3、引入自己编写的CSS文件时一定要放在其他...原创 2020-02-24 15:34:48 · 947 阅读 · 0 评论 -
pom.xml内容没错, 但第一行有红叉
在pom.xml文件加上<maven-jar-plugin.version>3.0.0</maven-jar-plugin.version><properties> <java.version>1.8</java.version> <maven-jar-plugin.version>3.0.0</maven-...原创 2020-02-10 22:35:25 · 930 阅读 · 0 评论 -
spriingboot -- spring-security 对页面资源的认证与授权
参考于和感谢此博主:https://www.cnblogs.com/zimug/p/11870861.html1、引入依赖和版本:1)、properties <properties> <java.version>1.8</java.version> <thymeleaf.version>3.0.9.RELEASE</thymele...原创 2020-01-30 21:54:22 · 355 阅读 · 0 评论 -
springboot -- 定时执行
1、主程序添加 @EnableSchedulingpackage com.example;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.sche...原创 2020-01-30 08:13:32 · 147 阅读 · 0 评论 -
springboot --发送邮件
1、引入依赖: <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-mail --> <dependency> <groupId>org.springframework.boot</groupId> &...原创 2020-01-29 17:28:50 · 322 阅读 · 0 评论 -
springboot -- 方法异步设置
1、主程序添加 @EnableAsync 开启异步package com.example;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.sched...原创 2020-01-29 16:35:05 · 327 阅读 · 0 评论 -
springboot -- 检索 Elasticsearch 初了解
一、用 jest 来作为检索工具1、引入依赖: <!-- https://mvnrepository.com/artifact/io.searchbox/jest --> <dependency> <groupId>io.searchbox</groupId> <artifactId>jest</a...原创 2020-01-28 20:27:56 · 166 阅读 · 0 评论 -
springboot -- Redis初了解与使用
1、启用Redis服务切换路径: cd /d F:\Redis开启Redis: redis-server.exe redis.windows.conf1、导入相关依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-...原创 2020-01-23 15:01:07 · 123 阅读 · 0 评论 -
springboot -- Cache缓存初了解
1、了解缓存缓存是为了提高运行性能:调用在缓存中已有的数据从而减少对数据库的操作。一个缓存管理器管理着多个缓存组件, 每个缓存组件有多个key, value键值对。举一个例子:一个公司(缓存管理器)有多个部门(缓存组件)它们都有自己的部门名称(cacheName),每个部门也有多个职员(key, value键值对)。其中键值对的储存方式是:key默认是方法参数的值的字符串, valu...原创 2020-01-22 09:28:55 · 261 阅读 · 0 评论 -
springboot -- 自定义starter
1、创建两个空项目 start、autoStart1)两个项目的关系是:start引用autoStart, 使用者只需要引用start即可2)相当于start为接口, 而实现它的是autoStart2、autoStart文件目录1)依赖引入 <!--spring-boot-starter是所有starter都要引入的基本配置 --> <dependency&g...原创 2020-01-20 14:17:25 · 131 阅读 · 0 评论 -
springboot -- JPA简单运用
1、导入相关依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> ...原创 2020-01-19 18:27:10 · 164 阅读 · 0 评论 -
springboot --Mybatis注解版和配置文件版
1、创建一个Mapper接口类package com.example.mapper;import org.apache.ibatis.annotations.Delete;import org.apache.ibatis.annotations.Insert;import org.apache.ibatis.annotations.Options;import org.apache.i...原创 2020-01-18 20:36:38 · 412 阅读 · 0 评论 -
连接mysql 出现:java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version></dependency>转载 2020-01-17 14:48:09 · 307 阅读 · 0 评论 -
springboot -- 自定义(可预知和不可预知) Exception 异常的抛出和统一捕获处理
1、首先自定义一个异常:public class UserNoExit extends RuntimeException{ public UserNoExit() { super("Not Exit..."); }}2、此处抛出一个异常:@ResponseBody@RequestMapping("/nihao")public String aa(@RequestParam(...原创 2020-01-13 23:18:13 · 1016 阅读 · 0 评论 -
springboot -- 异常错误页面初了解
通常我们的运行项目时映射地址输错了或者数据问题等等就会出现这个错误页面。而这个页面是springboot默认展示的页面。我们也可以利用 模板引擎 制作一个属于自己的错误页面在templates文件夹下创建error文件, 里面有404.html和4xx.html文件。(为什么要创建在这? 因为mvc的自动配置错误页面默认路径就是error文件夹下的与以状态码名字相关的html文件, 如...原创 2020-01-13 23:03:33 · 111 阅读 · 0 评论 -
springboot --前后端传输实体对象中引用对象无法被解析问题
除了添加getter和setter以外,有时候要注意一下自己如果另行添加了一个构造方法的话也要再创建一个空构造方法, 否则该对象无法被解析原创 2020-01-13 12:46:46 · 911 阅读 · 0 评论 -
springboot -- 后端接收前端字符串时间并且转换成Date
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")@DateTimeFormat(pattern = "yyyy-MM-dd")private Date birth;在实体Date类型属性上加@JsonFormat(pattern = “yyyy-MM-dd”, timezone = “GMT+8”)@DateTimeForm...转载 2020-01-13 10:49:34 · 6626 阅读 · 0 评论 -
springboot -- 用@RerquestBody接收前端数据 ajax的写法
$.ajax({ url:"addUser", type:"POST", data:JSON.stringify(data), contentType:"application/json", //缺失会出现URL编码,无法转成json对象 success:function(data){ ...原创 2020-01-11 19:49:50 · 685 阅读 · 0 评论 -
springboot -- 前后端接收数据
前言写一个项目总会编写前后端接收数据的, 但方法有很多, 但为了目前减轻一下我的脑子的压力, 我准备统筹一种方法去面对大部分前后端接收数据的方法正文后端@ResponseBody@PostMapping("/addUser") public User addUser(User user, String wocao){ //包装好的user对象 System.out.printl...原创 2020-01-11 19:34:42 · 555 阅读 · 0 评论 -
springboot -- thymeleaf重新跳转时的bug
出现这种情况有两种可能:1、像网上说的: 没有引用模板引擎的语句<html lang="en" xmlns:th="http://www.thymeleaf.org">2、<div th:text="${user.account}">这里显示欢迎信息</div>你没有把 user 对象传送到该页面中, 当 user 调用 account 属性时因为 u...原创 2020-01-11 12:05:17 · 126 阅读 · 0 评论 -
springboot -- 拦截器(HandlerInterceptor)
前言拦截器一般用于检测用户是否有登录, 防止未登录时用户直接输入映射地址跳转到需要登录的页面正文package com.atguigu.springboot.component;import org.springframework.web.servlet.HandlerInterceptor;import org.springframework.web.servlet.ModelAnd...原创 2020-01-10 12:19:13 · 413 阅读 · 0 评论 -
springboot --根据配置文件切换语言
一、配置语言文件在 resources 文件夹下创建一个文件夹local(自定义名称)来装三个配置文件success_en_US.properties文件(英文)success.name=Mr.Huangsuccess_zh_CN.properties(中文)success.name=\u9EC4\u5FA1\u633Asuccess.properties(默认中文)succe...原创 2020-01-10 10:52:39 · 793 阅读 · 0 评论 -
springboot --前端网页引用jar包依赖的做法
百度搜索 webjars 官网, 然后获取自己对应jar的依赖。比如Bootstrap<dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>4.4.1</version&g...原创 2020-01-09 19:25:15 · 734 阅读 · 0 评论 -
springboot -- 利用WebMvcConfigurerAdapter页面对于单纯的跳转功能的简化配置
@RequestMapping(value="/index") public String index(){ return "index"; }之前如果要单纯直接跳转一个页面的话要写一个映射方法, 但如果类似的要跳转很多个页面的话就要写很多个映射方法了@Configurationpublic class AdminPageController extends WebMvc...原创 2020-01-09 18:59:32 · 151 阅读 · 0 评论 -
springboot -- thymeleaf模板引擎的配置与使用
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>在pom.xml加入thymeleaf依赖<p...原创 2020-01-09 13:59:33 · 214 阅读 · 0 评论 -
springboot日志
springboot日志Logger logger = LoggerFactory.getLogger(getClass()); @Test public void contextLoads() { logger.trace("这是trace日志"); logger.debug("这是debug日志"); logger.info("这是Info日志"); logge...原创 2020-01-08 14:26:41 · 105 阅读 · 0 评论 -
JPA CriteriaBuilder 查询
JPA CriteriaBuilder 查询此文转载“月夜白狐”的博客园地址链接:https://www.cnblogs.com/g-smile/p/9177841.htmlCriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); //查询结果所需要的类型(Entity相对应)CriteriaQue...转载 2019-11-24 21:32:01 · 2451 阅读 · 0 评论 -
springboot如何单元测试
springboot如何单元测试pom.xml加上单元测试的依赖<!-- springboot test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artif...原创 2019-11-24 11:54:53 · 280 阅读 · 0 评论