- 博客(8)
- 问答 (4)
- 收藏
- 关注
原创 java:IO流递归查询目录下所有文件
public static void listDirectory(File dir) throws IOException { if (!dir.exists()) { throw new IllegalArgumentException("目录" + dir + "不存在"); } if (!dir.isDirectory()) { throw new IllegalArgumentException.
2020-06-07 01:55:00
300
原创 Spring:通过注解懒加载及初始化与销毁
通过注解懒加载:在Bean上加上@Lazy在@Configuration下加入@Lazy,则所有Bean都开启懒加载模式通过注解编写Bean初始化及销毁:1.将Bean的类实现DisposableBean接口 与 InitializingBean接口在destroy()方法 //销毁与afterPropertiesSet()方法//初始化下进行操作2.在自己写的销毁或者初始化方法上加上@PostConstruct //初始化@PreDestroy //销毁3.在@Bean中加ini
2020-06-05 02:54:35
485
原创 Spring: 通过注解设定Bean作用域:
在被管理的Bean上标明@Scope("")自定义作用域:在管理类中创建一个自定义作用域的方法并加上@Bean标签例如:` @Bean public MyScope myScope() { return new MyScope(); } @Bean public CustomScopeConfigurer customScopeConfigurer() { CustomScopeConfigurer customScopeConfigur
2020-06-05 01:56:05
305
原创 Spring:通过注解注入Bean
1.通过构造方法:在构造方法上加上注解@Autowired2.通过set方法:在get方法上加上注解@Autowired3.通过属性直接注入:在private属性上直接加@Autowired(不需要get set方法)4.通过list/set注入:现在的版本好像不支持,我测试起来会报错,没有深入研究了将多个泛型实例注入List时,可以用@Order(number) 来控制输出顺序,number越小,则优先级越大。5.简单类型的注入:是用@Value将值注入,并通过getSet方法来获取,输出6.
2020-06-04 17:25:02
314
原创 Spring:XML管理Bean vs Annotation
ApplicationContext ctx = new ClassPathXmlApplicationContext(""); 需改为ApplicationContext context = new AnnotationConfigApplicationContext(MyConfiguration.class); MyConfiguration类需要加上注解@Configuration 并在需要转成Bean的方法上加上注解@Bean,方法名则是方法名,...
2020-06-04 16:30:41
146
原创 Spring之三种方法实例化Bean
1.使用构造方法实例化BeanBean1public class Bean1 { public Bean1() { System.out.println("Bean.Bean"); }}SpringBeans.xml <bean id="bean1" class="com.Learn.Class.Bean1" />TestclassApplicationContext ctx=new ClassPathXmlApplicationC
2020-05-29 17:33:23
138
原创 Springboot:事务
事务特指数据库事务事务用@Transactional(spring提供的注解)MySql数据库用InnoDB引擎,支持事务
2020-05-27 17:01:50
163
原创 SpringBoot:jdbc serverTimezone以及编码格式设置
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: BeanPo.
2020-05-27 02:14:27
908
空空如也
jenkins SSH Publishers无法将新包发送到服务器上
2021-11-05
jquery append元素之后,css样式不生效 该如何解决?
2020-09-20
TA创建的收藏夹 TA关注的收藏夹
TA关注的人