标签文章:#springboot#

  • springboot全局的jackson日期转换和解析

    springboot全局的jackson日期转换和解析

    添加如下配置,接收+返回web数据时,统一格式化传参:@ConfigurationpublicclassWebConfigextendsWebMvcConfigurerAdapter{@OverridepublicvoidextendMessageConverters(List<HttpMessageConverter<?>>converters){MappingJacks......

    Nemo Nemo 2019.12.06 15:27 1142浏览 0回复

    阅读更多
  • springboot2.2.0 :Failed to bind properties under 'spring.servlet.multipart.max-file-size' to org.springframework.util.unit.DataSize

    之前用的都是springboot2.0及以前的版本配置都是这样子的 :spring:servlet:multipart:max-request-size:15Mbmax-file-size:15Mb然而springboot版本升级到2.2.0后,启动时提示:Failedtobindpropertiesunder'spring.servlet.multipart.max-file-size......

    Nemo Nemo 2019.10.23 11:18 2393浏览 0回复

    阅读更多
  • springboot 整合 redisson

    springboot 整合 redisson

    最近在做LinkNemo的调优工作,其中考虑引入redis,用来替代现有的队列/缓存机制。这里的redis客户端有两种待选,jedis和redisson。这边项目用的是redisson,用着感觉还可以,所以这里也考虑用redisson。以上是背景。开始:1、添加redisson的maven依赖:<!--redisson--><dependency><groupId&g......

    Nemo Nemo 2018.12.29 09:39 3022浏览 0回复

    阅读更多
  • Springboot 返回json,对空字段格式化

    一些json数据返回,例如list,map,字符串等,在为空的情况下,会直接给客户端返回为null,这时候客户端解析可能会出现处理,需要做一些处理列举一个Bean:@Data@ToStringpublicclassStudent{privateStringname;privateList<String>tags;}这时候,比如name和tags都为空,这时候序列化为json的结果:{"......

    Nemo Nemo 2018.06.14 19:13 3979浏览 0回复

    阅读更多
  • SpringBoot 注解事务声明式事务

    c、根据Advisor的匹配机制自动创建代理,会对容器中所有的Advisor进行扫描,自动将这些切面应用到匹配的Bean中,实现类DefaultAdvisorAutoProxyCreatorspringboot 对新人来说可能上手比springmvc要快,但是对于各位从springmvc转战到springboot的话,有些地方还需要适应下,尤其是xml配置。我个人是比较喜欢注解➕xml是......

    Nemo Nemo 2018.05.15 17:45 3414浏览 0回复

    阅读更多
  • 配置Spring Boot通过@ConditionalOnProperty来控制Configuration是否生效

    Springboot中有个注解@ConditionalOnProperty,这个注解能够控制某个configuration是否生效。具体操作是通过其两个属性name以及havingValue来实现的,其中name用来从application.properties中读取某个属性值,如果该值为空,则返回false;如果值不为空,则将该值与havingValue指定的值进行比较,如果一样则返回true;......

    Nemo Nemo 2018.05.15 16:11 3346浏览 0回复

    阅读更多
  • Spring Boot & Spring MVC 异常处理的N种方法

    原文出处:chanjarster默认行为根据SpringBoot官方文档的说法:FormachineclientsitwillproduceaJSONresponsewithdetailsoftheerror,theHTTPstatusandtheexceptionmessage.Forbrowserclientsthereisa‘whitelabel’errorviewthatrendersth......

    随遇而安 随遇而安 2018.03.30 18:41 1209浏览 0回复

    阅读更多
  • 深入 Spring Boot:怎样排查 expected single matching bean but found 2 的异常(转载)

    原文出处:hengyunabc写在前面这个demo来说明怎么排查一个常见的springexpectedsinglematchingbeanbutfound2的异常。https://github.com/hengyunabc/spring-boot-inside/tree/master/demo-expected-single调试排查expectedsinglematchingbeanbutfoun......

    随遇而安 随遇而安 2018.01.19 09:50 1231浏览 0回复

    阅读更多
  • 深入 Spring Boot:排查 @Transactional 引起的 NullPointerException(转载)

    原文出处:hengyunabc写在前面这个demo来说明怎么排查一个@Transactional引起的NullPointerException。https://github.com/hengyunabc/spring-boot-inside/tree/master/demo-Transactional-NullPointerException定位NullPointerException的代码Dem......

    随遇而安 随遇而安 2018.01.16 10:32 924浏览 0回复

    阅读更多
  • Unable to find a single main class from the following candidates[com.nemo.util.UuidUtil]

    有个项目是用springboot搭建的,在配置打包的时候出现了这个问题:Unabletofindasinglemainclassfromthefollowingcandidates[com.nemo.util.UuidUtil]查看错误,显然声称是UuidUtil的锅。然而其实并不然。解决方案是在打包插件中,添加启动class的配置即可。<plugin><groupId>o......

    Nemo Nemo 2017.12.18 10:35 4969浏览 0回复

    阅读更多
  • Springboot 过滤json中的特殊字符,避免xss攻击

    Springboot 过滤json中的特殊字符,避免xss攻击

    web安全中,xss防御是比较稀疏平常的。在使用springboot中,类似于普通的参数parameter,attribute,header一类的,可以直接使用过滤器来过滤。而前端发送回来的json字符串貌似没那么方便过滤了。一般在springboot中,前端传递json,后端使用@RequestBody来接收;而后端响应json发送至前端,则会使用@ResponseBody。这里考虑用自定义js......

    Nemo Nemo 2017.10.12 14:46 6119浏览 0回复

    阅读更多
  • Idea下,Springboot热部署配置

    1、开启idea的自动make功能:CTRL+SHIFT+A-->查找makeprojectautomatically-->选中CTRL+SHIFT+A-->查找Registry-->找到并勾选compiler.automake.allow.when.app.running2、使用spring-boot-1.3开始有的热部署功能:先在项目中添加maven依赖<depe......

    Nemo Nemo 2017.10.09 10:14 2957浏览 0回复

    阅读更多
  • springBoot+mybatis+mysql+druid多数据源配置

    springBoot+mybatis+mysql+druid多数据源配置

    一多数据源应用场景当业务数据量达到了一定程度,DBA需要合理配置数据库资源。即配置主库的机器高配置,把核心高频的数据放在主库上;把次要的数据放在从库,低配置。即把数据放在不同的数据库里,就需要通过不同的数据源进行操作数据。二配置项目结构图pom.xml<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.a......

    CODY CODY 2017.06.01 20:34 1894浏览 6回复

    阅读更多
  • Spring Boot 让 MyBatis 打印日志

    使用springboot默认会打印日志在控制台,但是他默认是不输出到文件的,所以要配置输出路径,那么还要写输出路径,默认情况下,SpringBoot将仅登录到控制台,不会写日志文件。如果要编写除控制台输出之外的日志文件,则需要设置logging.file或logging.path属性(例如在application.yml中)。写入指定的日志文件。名称可以是确切的位置或相对于当前目录。将spring......

    Nemo Nemo 2017.05.23 09:32 1676浏览 0回复

    阅读更多
  • Springboot 打包发布到tomcat

    第一步:将这个SpringBoot项目的打包方式设置为war<version>0.0.1</version><packaging>war</packaging>第二步去掉springboot中内嵌的tomcat模块,修改pom文件<dependency><groupId>org.springframework.boot<......

    Nemo Nemo 2017.05.02 17:18 3084浏览 0回复

    阅读更多
  • Spring Boot 部署与服务配置

    springBoot其默认是集成web容器的,启动方式由像普通Java程序一样,main函数入口启动。其内置Tomcat容器或Jetty容器,具体由配置来决定(默认Tomcat)。当然你也可以将项目打包成war包,放到独立的web容器中(Tomcat、weblogic等等),当然在此之前你要对程序入口做简单调整。项目构建我们使用Maven或Gradle,这将使项目依赖、jar包管理、以及打包部署变......

    Nemo Nemo 2017.04.10 09:35 4237浏览 0回复

    阅读更多
  • Springboot添加swagger支持

    添加maven依赖:<!--swaggerstart--><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.2.2</version></dependen......

    Nemo Nemo 2017.04.01 14:56 5088浏览 6回复

    阅读更多
  • Spring Boot允许跨域请求

    Springboot默认是禁止跨域请求的。可以添加配置类打开:packagecom.nemo.common.configs;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;importorg.springframework.web......

    Nemo Nemo 2017.03.20 22:43 4079浏览 0回复

    阅读更多
  • Springboot | Failed to execute goal org.springframework.boot:spring-boot-maven-plugin

    在整理springboot的基本架构时,某一个层在build的时候发生了如下异常:[INFO]Scanningforprojects...[INFO][INFO]------------------------------------------------------------------------[INFO]Buildingentity0.0.1-SNAPSHOT[INFO]-------......

    Nemo Nemo 2017.03.20 19:39 2361浏览 0回复

    阅读更多