![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ssm-spring
文章平均质量分 70
qq_三哥啊
一个热爱学习的爪哇程序员
展开
-
@Future对LocalDate不生效的问题
*** 未来LocalDateMETHOD , FIELD , ANNOTATION_TYPE , CONSTRUCTOR , PARAMETER , TYPE_USE }) // 将注解标记为 Bean Validation 约束 @Constraint(validatedBy = {/*** 错误提示信息*/ String message() default "日期必须大于今天";/*** 分组信息,容许指定此约束所属的验证组* @return};/**......原创 2022-08-02 21:18:44 · 100 阅读 · 0 评论 -
【Spring】@Transactional的事务传播方式REQUIRED、REQUIRES_NEW、NESTED
参考spring事务传播之required nested requires_newSpring框架(事务传播行为)补充NESTED是为被嵌套的方法开启了一个子事务,这个事务与父类使用的是同一个连接。REQUIRES_NEW是使用一个全新的事务,这个事务属于另外一条全新的连接。两者最重要的体现,就是在多数据源中,REQUIRES_NEW会再次触发一下数据源的获取,而NESTED则不会。NESTED开始一个 “嵌套的” 事务, 它是已经存在事务的一个真正的子事务。嵌套事务开始执行时, 它将取得原创 2021-12-30 16:54:42 · 1412 阅读 · 0 评论 -
【Spring】SpEL(即Spring的表达式语言)
遗漏知识点语法使用#{...}作为界定符,所有在大括号中的字符都将被认为是SpEL字面量的表示整数:#{666}String:可以用单引号或双引号作为字符串的界定符,#{‘Tom’}Boolean:#{true}、#{false}运算符算术运算符:+、-、*、/、%、∧+号还可以作为字符串拼接符比较运算符:<、>、==、<=、>=、lt、gt、eq、le、ge逻辑运算符:and、or、not、&&、||判空运算符:#{user.n原创 2021-12-25 21:47:51 · 343 阅读 · 0 评论 -
【Spring】bean的三种初始化方法及它们的执行顺序
如果使用不同的方式为同一个bean配置了多个不同的初始化方法,执行顺序如下所示:Methods annotated with @PostConstructafterPropertiesSet() as defined by the InitializingBean callback interfaceA custom configured init() method若不同方式配置了同一个方法,例如init(),name这个方法只会执行一次。销毁方法的顺序执行也是一样的:M原创 2021-04-20 00:14:29 · 1407 阅读 · 0 评论 -
【Spring】注解驱动教程
文章目录前言11讲:27讲:38讲:40讲:46讲:前言视频:尚硅谷Spring注解驱动教程(雷丰阳源码级讲解)笔记:史上最详细的Spring注解驱动开发系列教程本博客是对上述笔记的补充。11讲:没有分析FactoryBean的原理,见DefaultListableBeanFactory#preInstantiateSingletons、AbstractBeanFactory#doGetBean、AbstractBeanFactory#getObjectForBeanInstance27讲:原创 2021-04-13 23:32:34 · 204 阅读 · 1 评论 -
【Spring】常用扩展点及其应用场景
包括各种自定义处理PostProcessor(后置处理器)和各种感知IOC容器的Aware(觉察)BeanDefinitionRegistryPostProcessor接口BeanFactoryPostProcessor接口public interface BeanFactoryPostProcessor { /** * Modify the application context's internal bean factory after its standard * initial原创 2021-04-13 14:07:56 · 1578 阅读 · 0 评论 -
【Spring】IOC容器的创建过程
创建AnnotationConfigApplicationContextAnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MainConfig.class);AnnotationConfigApplicationContext初始化public class AnnotationConfigApplicationContext extends GenericApplicationContext原创 2021-04-13 13:55:06 · 352 阅读 · 0 评论 -
【Spring】依赖版本管理Spring IO Platform
参考链接参考链接当然SpringSource为了解决这些Jar冲突,推出了各种BOM,当然最著名的就是spring platform io bom,其中最核心的三个是:spring-framework-bom、spring-boot-dependencies、platform-bom。spring-framework-bom、spring-boot-dependencies、io.spring.platform的关系与区别参考链接spring-framework-bom:只管理SpringFram原创 2021-02-26 00:40:57 · 1038 阅读 · 0 评论 -
Spring中Junit测试-@WebAppConfiguration与WebApplicationContext
先看看Spring官方的注释说明//@WebAppConfiguration是一个类级注释,用于声明集成测试加载的ApplicationContext应该是WebApplicationContext。//Spring会以value属性(默认为"src/main/webapp")指定的目录路径来为测试加载WebApplicationContext。要覆盖默认值,请通过value属性指定一个显式资源路径。//请注意, @WebAppConfiguration必须在单个测试类中或在测试类层次结构中与@Con原创 2021-02-06 15:10:31 · 4883 阅读 · 3 评论 -
Spring中Junit测试启动报错class path resource [xxx.xml] cannot be opened because it does not exist
文章目录问题分析解决问题本地开发项目时,直接将项目部署到idea配置的tomcat中能正常启动,但是使用Spring的junit测试时,启动报错class path resource [xxx.xml] cannot be opened because it does not exist。分析在测试类构造方法上获取当前测试环境的classpath路径然后去这个classpath路径看一下,发现确实没有xml配置文件。说明是我们的配置文件没有成功编译输出。再去确认一下我们设置的test模块的编译输原创 2021-02-06 12:52:31 · 2954 阅读 · 0 评论 -
spring中使用@value注入static静态字符串变量
问题import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Component; @Componentpublic class SystemUtil { @Value("${login.url}") public static String LOGIN_URL;}运行时发现静态属性LOGIN_URL的值为null,@Value注入失败。分析原创 2021-01-29 09:48:34 · 1699 阅读 · 0 评论 -
spring中各种容器context理解汇总(待续)
spring容器启动初始化流程AbstractApplicationContext.obtainFreshBeanFactory() AbstractRefreshableApplicationContext#refreshBeanFactory() XmlWebApplicationContext#loadBeanDefinitions(DefaultListableBeanFactory) XmlWebApplicationContext#loadBeanDefinitions原创 2021-01-28 15:14:41 · 523 阅读 · 0 评论 -
spring-profile详解
前言Spring提供了@Profile注解来实现按照不同的环境装配不同的bean,进而实现程序只需构建一次,但可以部署到多个环境。动态生成相应的beanProfile工作原理Profile的使用步骤1.定义各种profile对应的beanxml方式:javaConfig方式(@Profile注解):2.启用指定的profilespring.profiles.active和spring.profiles.default启用方式WebApplicationInitializer接口原创 2021-01-28 11:47:05 · 1116 阅读 · 0 评论 -
spring中依赖注入@Value和@Autowired的使用
可以写在何处@Value可以写在变量、方法(包括构造方法)入参、只有一个参数的方法(包括构造方法)上@Autowired可以写在变量、方法(包括构造方法)上在spring4.x中新增了新的特性:如果类只提供了一个带参数的构造方法,则不需要对其内部的属性写@Autowired注解,spring会自动为你注入属性;配合lombok的@RequiredArgsConstructor使用体验很好。@Value与@Autowired混合使用执行到有@Autowired的构造方法时:执行到有@Po原创 2021-01-29 12:56:00 · 3187 阅读 · 0 评论 -
部署项目时项目启动两次及每次启动@PostConstruct执行两次问题
由于tomcat的server.xml中配置的该项目的path与项目名不一致导致的。原创 2019-10-16 17:35:52 · 1337 阅读 · 0 评论 -
【Spring】Initialization of bean failed; nested exception is java.lang.IllegalStateExcepti
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.DefaultTestContext.getApplica原创 2020-08-06 18:25:27 · 4203 阅读 · 0 评论 -
【Spring】异步任务注解@Async、@EnableAsync、@EnableScheduler、@Scheduled
Spring中用@Async注解标记的方法,称为异步方法,其实就相当于我们自己在当前方法里面:new Thread(()-> System.out.println(“hello world !”))。按@Async注解使用的基本方法:在方法上添加@Async注解;所使用的@Async注解方法的类对象应该是Spring容器管理的bean对象;调用异步方法的类上需要配置上注解@EnableAsync异步不生效问题不要同类方法调用异步方法所在类的另一个方法调用这个异步方法,异步不会生效!原创 2020-06-19 08:35:46 · 1355 阅读 · 0 评论 -
【Spring】context:component-scan包扫描问题
Spring 项目bean 无法注入或者初始化,可能是扫描问题,下面分两种情况研究1.配置的bean 没有被扫描先说一下<context:component-scan base-package=“com.summer”> ,这个标签有一个use-default-filters属性,该属性默认为true(表示扫描到有@Component @Controller@Service @Re...原创 2019-11-13 11:25:55 · 3501 阅读 · 0 评论