随笔分类 -  spring

1 2 3 下一页

Spring之 IoC、BeanFactory、ApplicationContext
摘要:IoC (Inverse of Control) IoC ,也就是 控制反转。 对于软件来说,即某一接口具体实现类的选择控制权从调用类中移除,转交给第三方决定,即由Spring容器借由Bean配置来进行控制。 Martin Fowler提出了DI(Dependency Injection,依赖注入) 阅读全文

posted @ 2024-07-07 16:08 乐之者v 阅读(7) 评论(0) 推荐(0) 编辑

@Cacheable 注解的 @CacheManager 示例
摘要:@Cacheable 注解的使用 开发中经常会使用Redis 缓存,可以使用 @Cacheable 相关的注解来操作缓存。 详情见:https://blog.csdn.net/sinat_32502451/article/details/134310654 CacheManager @Cacheab 阅读全文

posted @ 2023-08-08 01:27 乐之者v 阅读(158) 评论(0) 推荐(0) 编辑

@Cacheable 、 @CachePut 、@CacheEvict 注解
摘要:使用场景 在开发中,需要使用缓存时,可以使用 @Cacheable 、 @CachePut 、@CacheEvict 注解。 注意: @Cacheable 、 @CachePut 、@CacheEvict 是基于 Aop 动态代理实现的。 因此,如果在同一个类里面,调用 @Cacheable 注解的 阅读全文

posted @ 2023-08-07 22:39 乐之者v 阅读(355) 评论(0) 推荐(0) 编辑

实践理解 Transactional 是否生效
摘要:实践理解 Transactional 是否生效 示例: 新建一个订单表 tb_order_test 。 手动插入一条数据。 然后在代码中,根据 id 更新,如果更新成功,那么 update_time 会变化。 代码中执行 1/0; 由于 0不能做为除数,代码会抛异常。 通过 updateTime 观 阅读全文

posted @ 2023-07-14 11:16 乐之者v 阅读(100) 评论(0) 推荐(0) 编辑

@PostConstruct的使用
摘要:### @PostConstruct 以Post为前缀的单词,指 在...之后。比如 postgraduate 就有大学毕业后的意思。 Construct 是构造方法。 @PostConstruct 是指在构造方法之后运行的意思。 ### 执行顺序: Constructor(构造方法) -> @Po 阅读全文

posted @ 2023-06-16 00:01 乐之者v 阅读(185) 评论(0) 推荐(0) 编辑

@Configuration配置 @Bean
摘要:### @Configuration 和 @Bean * @Configuration 用于定义配置类,作用在类上。 * @Bean 用于定义 Bean对象,作用在方法上。 @Configration 注解类中可以声明一个或多个 @Bean 方法 ### User 类 ``` public clas 阅读全文

posted @ 2023-06-15 22:59 乐之者v 阅读(115) 评论(0) 推荐(0) 编辑

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '' available: expected at least 1 bean which qualifies as autowire candidate.
摘要:问题描述 Spring报错: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '' available: expected at least 阅读全文

posted @ 2022-07-20 21:56 乐之者v 阅读(342) 评论(0) 推荐(0) 编辑

IDEA启动项目报错:Caused by: java.io.FileNotFoundException: class path resource [.properties] cannot be opened because it does not exist
摘要:IDEA启动项目报错 Caused by: java.io.FileNotFoundException: class path resource [.properties] cannot be opened because it does not exist 解决方法: 1.检查文件的路径是否正确, 阅读全文

posted @ 2022-01-24 21:29 乐之者v 阅读(4481) 评论(0) 推荐(0) 编辑

ApplicationContext在非Service类中调用Spring的Serivce类
摘要:背景 有时我们需要在一些不属于Spring的类中,去调用Spring的Service类的方法。 比如,在Util类,或者main()方法中,去调用Service类的方法。 这时,可以使用 ApplicationContextAware接口 和 ApplicationContext接口 . Appli 阅读全文

posted @ 2021-10-25 11:57 乐之者v 阅读(201) 评论(0) 推荐(0) 编辑

java web开发中Servlet、Request、Response常用的代码
摘要:Request(请求) 1.获取并打印request的body中的参数。 这种获取请求中代码,一般都会封装成工具类。 如果不封装,写起来比较麻烦,类似如下: JSONObject res = new JSONObject(); String postData = null; try { postDa 阅读全文

posted @ 2019-06-08 23:02 乐之者v 阅读(534) 评论(0) 推荐(0) 编辑

Spring重定向
摘要:1.使用HttpServletResponse的sendRedirect()方法。 示例: 2.返回"redirect:"加上url。 注意:这种方式,不能使用@RestController和@ResponseBody,否则只会返回一堆字符串。 如下: 参考资料: https://blog.csdn 阅读全文

posted @ 2019-05-27 23:04 乐之者v 阅读(501) 评论(0) 推荐(0) 编辑

@PathVariable不起作用,报错:Cannot resolve @PathVariable ' '
摘要:@PathVariable是占位符注解。可以把Url中变量的值传递到方法参数中。 示例如下: 当我们输入的Url类似于 localhost:8080/user/name/1时,Controller层对应方法getUserName的参数id就会赋值为1。 但是要注意: 1.控制层的Url占位符{}中的 阅读全文

posted @ 2019-05-26 22:50 乐之者v 阅读(4087) 评论(0) 推荐(0) 编辑

Request method 'GET' not supported
摘要:Request method 'GET' not supported 错误原因: GET请求不被允许。 解决方法: 1.从客户端入手。假设浏览器中的js用了ajax发起异步请求GET,将GET改为POST。 2.从服务端入手。Controller层的 @RequestMapping( method 阅读全文

posted @ 2018-08-30 14:49 乐之者v 阅读(9690) 评论(0) 推荐(0) 编辑

Required String parameter ' ' is not present
摘要:Required String parameter ' ' is not present 报错原因: url中的参数错误。 解决方法: 1.修正url中的参数的值。 2.在Controller层中的@RequestParamrequired = false 也就是 @RequestParam(val 阅读全文

posted @ 2018-08-30 14:45 乐之者v 阅读(9480) 评论(0) 推荐(0) 编辑

Ssm框架常见报错
摘要:错误1: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. 解决方案: http://www.c 阅读全文

posted @ 2018-07-16 11:19 乐之者v 阅读(1460) 评论(0) 推荐(0) 编辑

如何阅读一个Web项目 【转载】
摘要:摘自网络博客。 学会如何读一个JavaWeb项目源代码 步骤:表结构->web.xml->mvc->db->spring ioc->log->代码 1、先了解项目数据库的表结构,这个方面是最容易忘记的,有时候我们只顾着看每一个方法是怎么进行的,却没有去了解数据库之间的主外键关联。其实如果先了解数据库 阅读全文

posted @ 2018-07-11 17:01 乐之者v 阅读(466) 评论(0) 推荐(0) 编辑

springmvc 请求无法到达controller,出现404
摘要:今天在配置SpringMVC时,访问项目一直出现404,无法访问。 报错: The origin server did not find a current representation for the target resource or is not willing to disclose th 阅读全文

posted @ 2018-07-09 15:59 乐之者v 阅读(10353) 评论(0) 推荐(0) 编辑

spring集成mybatis配置多个数据源,通过aop自动切换
摘要:spring集成mybatis,配置多个数据源并自动切换。 spring-mybatis.xml如下: spring-mvc配置如下: Dao层如下: EsbTraceDao如下: WorkOrderDao如下: Service层的如下: EsbTraceServiceImpl.java如下: 注意 阅读全文

posted @ 2018-06-22 15:57 乐之者v 阅读(1471) 评论(0) 推荐(0) 编辑

java普通类如何调用Spring的Service层?
摘要:首先在Service层上面添加 @Service("myService") 然后,在main方法中调用,String[]中为配置文件,如下所示: 阅读全文

posted @ 2018-06-11 21:15 乐之者v 阅读(1370) 评论(0) 推荐(0) 编辑

Quartz任务调度
摘要:一、基本概念 在java中,可以通过Quatz框架来实现定时任务。 Quartz主要包括以下部分: 1.scheduler:调度器,可以把任务和触发器注册到任务调度器中,然后启动调度器。 2.Trigger :触发器,包括SimpleTrigger和CronTrigger。CronTrigger可以 阅读全文

posted @ 2018-05-14 23:11 乐之者v 阅读(217) 评论(0) 推荐(0) 编辑

1 2 3 下一页
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示