摘要: 原创出处:www.bysocket.com 泥瓦匠BYSocket 希望转载,保留摘要,谢谢! “年轻人不要怕表现,要敢于出来表现,但还是那句话,要有正确的度,你的表现是分析问题和解决问题的能力.” – <你凭什么做好互联网> 本文提纲一.异常统一处理的使用场景二.运行 springboot-validation-over-json 工程三.springboot-validation-over-json 工程代码详解 一.异常统一处理的使用场景 在前后端分离开发中,经常用 HTTP o…
spring boot @ResponseBody转换JSON 时 Date 类型处理方法 ,这里一共有两种不同解析方式(Jackson和FastJson两种方式,springboot我用的1.x的版本) 第一种方式:默认的json处理是 jackson 也就是对configureMessageConverters 没做配置时 mybatis数据查询返回的时间,是一串数字,如何转化成时间.两种方法,推荐第一种 方法一: 可以在apllication.property加入下面配置就可以 #时间戳统…
Spring Boot 之使用 Json 详解 简介 Spring Boot 支持的 Json 库 Spring Web 中的序列化.反序列化 指定类的 Json 序列化.反序列化 @JsonTest Spring Boot 中的 json 配置 Jackson 配置 GSON 配置 Spring Boot 中使用 Fastjson 示例源码 引申和引用 简介 Spring Boot 支持的 Json 库 Spring Boot 支持三种 Json 库: Gson Jackson JSON-B…
spring boot启动STS 运行报错 java.lang.NoClassDefFoundError: ch/qos/logback/classic/LoggerContext 学习了: http://ask.csdn.net/questions/381580 http://blog.csdn.net/liuxiangke0210/article/details/77893560?locationNum=2&fps=1 增加了: <dependency> <groupId&g…
Spring Boot Security And JSON Web Token 说明 流程说明 何时生成和使用jwt,其实我们主要是token更有意义并携带一些信息 https://github.com/Ants-double/huanhuncao/tree/master/visio 实操准备 新建一个spring boot 项目,并添加hello请求 工程目录结构如下 HelloWorldController 代码如下 package com.antsdouble.demojwt.contro…
1.步骤: 1. 编写实体类Demo 2. 编写getDemo()方法 3. 测试 2.项目构建 编写实体类Demo package com.kfit; /** * 这是一个测试实体类. */ public class Demo { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getN…
MVC框架中,Spring Boot内置了jackson来完成JSON的序列化和反序列化操作,并且,在与其他技术集成的时候,如Redis.MongoDB.Elasticsearch等对象序列化,都可使用jackson来完成. Spring Boot 之遇见JSON Spring Boot中使用Jackson 自定义ObjectMapper Jackson的三种使用方式 Jackson树遍历 对象绑定 流式操作 Jackson注解 集合的反序列化 Spring Boot中使用Jackson 在Co…
在spring boot jpa 中自定义sql,执行update操作报错解决办法: 在@Query(...)上添加 @Modifying@Transactional注解…
方案一:启动类继承WebMvcConfigurerAdapter,覆盖方法configureMessageConverters ... @SpringBootApplication public class UserApplication extends WebMvcConfigurerAdapter{ @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters)…
转载请注明出处... 一.介绍 用过springMVC/spring boot的都清楚,在controller层接受参数,常用的都是两种接受方式,如下 /** * 请求路径 http://127.0.0.1:8080/test 提交类型为application/json * 测试参数{"sid":1,"stuName":"里斯"} * @param str */ @RequestMapping(value = "/test",…
使用Spring boot整合Hive,在启动Spring boot项目时,报出异常: java.lang.NoSuchMethodError: org.eclipse.jetty.servlet.ServletMapping.setDefault(Z)V 经过排查,是maven的包冲突引起的,具体做法,排除:jetty-all.hive-shims依赖包.对应的pom配置如下: <dependency> <groupId>org.apache.hive</groupId&g…
解决参考文章:https://blog.csdn.net/hengyunabc/article/details/78762097 spring boot启动报错如下: Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. -- :: --- [ main] o.s.b.d.LoggingFailureAnal…
此文章已经废弃,请看新版的博客的完美解决方案: 78. Spring Boot完美使用FastJson解析JSON数据[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/blog/2315202 [Spring Boot 系列博客] 58. Spring Boot国际化(i18n)[从零开始学Spring Boot] 57. Spring 自定义properties升级篇[从零开始学Spring Boot] 56. spring boot中使…
在使用Spring Boot JPA分页 PageRequest分页时,出现如下错误: 本来以为是包导入出现了问题,结果发现并不是.导入包如下: 后来在网上查找相关资料,发现这样的用法,好像也可以用,但他们提示的都是此方法已过期.我的不知道为什么报错了. 后来去源码里找了一下这个方法,发现源码中方法如下: 于是把上面报错的代码修改为: Pageable pageable1 = PageRequest.of(0, 11, Sort.Direction.ASC, "orderNo"); 错…
spring boot用layout ZIP打出来的包能够支持外部classpath,但是当用rar/7zip替换其中的jar后,报下列错误: Unable to open nested entry 'BOOT-INF/lib/cache-api-0.4.jar'. It has been compressed and nested jar files must be stored without compression. 解决方法: jar包可以替换的,过程如下:jar -xvf ta-bas…
hello,大家好,我是小黑,又和大家见面啦~ 今天我们来继续学习 Spring Boot GraphQL 实战,我们使用的框架是 https://github.com/graphql-java-kickstart/graphql-spring-boot 本期,我们将使用 H2 和 Spring Data JPA 来构建数据库和简单的查询,不熟悉的同学可以自行去网上查阅相关资料学习. 完整项目 github 地址:https://github.com/shenjianeng/graphql-sp…
启动报错: 2018-05-16 17:22:58.161 ERROR 4080 --- Disconnected from the target VM, address: '127.0.0.1:50529', transport: 'socket' [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START **********…
@RequestMapping("/json")public void json(HttpServletResponse response, Pager pager, TruckFee entity) throws IOException{ response.addHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Content-Type", &qu…
package com.sample.smartmap.controller; import java.io.IOException; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactor…
我拷贝了一个springboot 项目,然后去掉了数据源配置启动报错 : Cannot determine embedded database driver class for database type NONE Action: If you want an embedded database please put a supported one on the classpath. 然后我新建一个项目重新配置(没有配置数据源),启动还是报错这个 加入这个,搞定....项目启动不去加载就好了 参…
原文:https://blog.csdn.net/u__f_o/article/details/82756701 一般出现这种情况,应该是没有扫描到对应的mapper包,即在启动类下配置MapperScan时导错了包. 此时应该导入的包是 tk.mybatis.spring.annotation.MapperScan, 而不是 org.mybatis.spring.annotation.MapperScan…
问题1, [ERROR]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project motherBuyBoot: There are test failures. [ERROR] Please refer to D:\web\motherbuy\target\surefire-reports for the individual test r…
错误: org.thymeleaf.exceptions.TemplateInputException: Error resolving template "Hello", template might not exist or might not be accessible by any of the configured Template Resolvers at org.thymeleaf.TemplateRepository.getTemplate(TemplateReposi…
如果你遇见下面的错误,很可能是你的springboot和es版本关系不对应 ERROR 14600 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#…
------错误处理机制------ 默认效果 1 返回一个默认的错误页面 浏览器发送请求的请求头:优先接收 text/html 数据 客户端则默认响应json数据 : accept 没有说明返回什么数据 默认返回json 原理:参照 ErrorMvcAutoConfiguration 错误的自动配置 1 DefaultErrorAttributes // 帮助我们共享页面信息 public Map<String, Object> getErrorAttributes(WebRequest w…
场景 网站localhost:56338要访问网站localhost:3001的服务 在网站localhost:3001中增加CORS相关Java Config @Configuration @Order(Ordered.HIGHEST_PRECEDENCE) public class CORSConfiguration { @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter()…
如何返回 JSON 数据? 在 Spring Boot 中返回 JSON 数据很简单,如下几步. 加入依赖 12345678910 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.4.RELEASE</version></paren…
1.Spring boot,Mybatis 启动报错 Failed to auto-configure a DataSource *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datas…
 Spring Boot返回json数据 视频地址:http://www.iqiyi.com/w_19rubxzsr5.html 博文参考:https://blog.csdn.net/linxingliang/article/details/51582294 Spring Boot完美使用FastJson解析Json数据   视频地址: http://baidu.iqiyi.com/watch/0669833408793393358.html 博文参考:https://my.oschina.ne…
[原创文章,转载请注明出处] 个人使用比较习惯的json框架是fastjson,所以spring boot默认的json使用起来就很陌生了,所以很自然我就想我能不能使用fastjson进行json解析呢?        引入fastjson依赖库: <dependencies> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> &…