![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
springboot
springboot框架遇到的开发问题总结
WD技术
这个作者很懒,什么都没留下…
展开
-
SpringBoot 中发布ApplicationEventPublisher,监听ApplicationEvent 异步操作
https://blog.csdn.net/weixin_43770545/article/details/105971971原创 2022-02-18 21:25:51 · 267 阅读 · 0 评论 -
@NotEmpty,@NotNull和@NotBlank的区别
1.@NotNull不能为null,但可以为empty (""," “,” ")2.@NotEmpty不能为null,而且长度必须大于0 (" “,” ")3.@NotBlank只能作用在String上,不能为null,而且调用trim()后,长度必须大于0 (“test”) 即:必须有实际字符...原创 2022-02-18 14:24:44 · 139 阅读 · 0 评论 -
@Valid 注解用法详解
首先我们在 Employee 类的属性上打上如下注解:package com.zyq.beans; import javax.validation.constraints.NotBlank;import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.Length;import org.hibernate.validator.constraints.Range; /** *原创 2022-02-18 14:21:56 · 472 阅读 · 0 评论 -
JSON.toJSONString(object, SerializerFeature.WriteMapNullValue);第二个参数作用
fastjson是由alibaba开源的一套json处理器。与其他json处理器(如Gson,Jackson等)和其他的Java对象序列化反序列化方式相比,有比较明显的性能优势如图:这里箭头指向的位置,因为sent-1 中的value为空,所以并未打印出来。第二个使用:JSON.toJSONString(map, SerializerFeature.WriteMapNullValue) 指定序列化方式就打印出来了...原创 2022-02-17 20:20:14 · 2241 阅读 · 0 评论 -
注解@Slf4j的使用
分析:如果不想每次都写private final Logger logger = LoggerFactory.getLogger(当前类名.class);可以用注解@Slf4j省略这行代码前提:1.使用idea首先需要安装Lombok插件2、在pom文件加入lombok的依赖<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</arti原创 2022-01-13 23:06:31 · 143 阅读 · 0 评论 -
Failed to bind properties under ‘logging.level‘ to java.util.Map java.lang.String, java.lang.String
springBoot 2.0 添加 日志级别,启动报错:logging: level: info修改成logging: level: root: info原创 2022-01-13 20:01:42 · 188 阅读 · 0 评论 -
springboot 启动类注解 @SpringBootApplication 和 @ComponentScan 的问题
问题:在启动类Application上使用@ComponentScan 这个注解来扫描第三方的包,然后就会出现报错,异常就是无法加载本地的某些类,例如某些Dao无法注入.分析:启动类注解 @SpringBootApplication 其实就包含了 @ComponentScan 注解,如果同时用了,@SpringBootApplication 注解自带的 @ComponentScan 注解就不生效了解决办法:1、可以在@ComponentScan 里边把本地的路径给加上,这样就可以解决问题了,即可以原创 2022-01-07 20:22:19 · 2564 阅读 · 0 评论 -
springboot多模块项目,无法找到另一个模块的实体类
原因分析:有两个模块,他们的目录结构都是一样的,比如实体类都在com.wd.spring.pojo包下,你在一个模块中引用另一个模块中的实体类时,它就不会去那个模块找,而在本模块找解决办法:让两个模块的目录机构不一样即可模块一:com.wd.spring1.pojo模块二:com.wd.spring2.pojo...原创 2022-01-06 11:33:03 · 2386 阅读 · 0 评论 -
Property ‘configuration‘ and ‘configLocation‘ can not specified with together
错误原因已经提示的很清楚了 configuration 和 configLocation 不能同时存在 也就是说:在spring的配置文件指定了mybatis的配置文件 就不能在spring的配置里面写入mybatis的配置,所以报错去除spring配置文件下的关于mybatis 的配置 也就是 mybatis.configuration 相关配置...原创 2022-01-06 10:50:11 · 483 阅读 · 0 评论 -
spring-boot项目打包时候出现boot-inf文件夹的问题
1.spring-boot maven打包,一般pom.xml文件里会加<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId></plugin>这样打的jar里会多一个目录BOOT-INF。2.引起问题,程序包不存在。3.解决办法,如果A子模块包依赖了B子模原创 2021-12-07 20:42:54 · 1037 阅读 · 0 评论 -
idea 下载不了springboot源码
1、cmd 进入项目的根目录2、执行命令 mvn dependency:resolve -Dclassifier=sources原创 2021-11-18 21:27:54 · 616 阅读 · 0 评论 -
@Mapper和@Repository的区别
1.相同点@Mapper和@Repository都是作用在dao层接口,使得其生成代理对象bean,交给spring 容器管理,对于mybatis来说,都可以不用写mapper.xml文件2.不同点@Repository需要在Spring中配置扫描地址,然后生成Dao层的Bean才能被注入到Service层中:如下,在启动类中配置扫描地址:@Mapper不需要配置扫描地址,通过xml里面的namespace里面的接口地址,生成了Bean后注入到Service层中也就是@Repository多了一原创 2021-11-03 23:22:39 · 462 阅读 · 0 评论