2月6日-备孕春招40天-第25天

①leetcode

复习:81-90

股票最大值1

https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/solution/gu-piao-1-by-19216801-eoq9/

股票最大值2

https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/solution/mai-mai-gu-piao-2-by-19216801-wp59/

股票最大值3

https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/solution/gu-piao-3-by-19216801-2ucu/

二叉树最大路径:(递归的方法,分为该节点参与和该节点不参与)

https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/solution/

回文字符串

https://leetcode-cn.com/problems/valid-palindrome/solution/

② 剑指offer

数组中的逆序对、链表的第一个公共节点

③ spring

①编写业务层持久层接口 ②在xml中声明,要扫描的包 <context:component-scan base-package="com.yan"></context:component-scan> ③在需要让IOC管理的类或者注入的数据上添加相应的注解

新注解:

  • @Configuration :声明配置类
  • 当配置类作为AnnotationConfigApplicationContext对象创建参数时,该注解可以不写
  • @ComponentScan :容器的扫描包(IOC在这些包中收集注解的类和数据对象)
  • 属性:value:IOC容器要扫描的包
  • 相当于:
  • <context:component-scan base-package="com.yan"></context:component-scan>
  • @Bean : 作用:用于把当前方法的返回值作为bean对象存入spring的ioc容器中
  • 属性:name:指定bean的id。默认值是当前方法名称
  • @Import :用于导入其他的配置类,一般用于把其他配置类导入到主配置类。
  • 属性:value:指定其他配置类的字节码
  • @PropertySource :用于指定properties文件的位置
  • 属性:value:指定文件名称和路径,关键字:classpath指定类路径(多几个空格都不行)

alt

用value注解拿properties中的数值使用

alt

多例Queryrunner放入IOC

alt

4)spring和junit的整合(实际上就是可以在测试中使用IOC(写spring的注解或者xml)) 为什么需要整合? ① junit单元测试没有main方法也能执行 该方法判断当前类有哪些方法有@Test注解 junit就让有Test注解的方法执行 ②junit不知道使没使用spring框架,不会主动创建IOC ③执行测试方法时,就是写了Autowired也没用

整合方法?

  • spring整合junit的配置
  • 1,导入spring整合junit的jar包
  • 2,使用junit注解把原有的main方法替换,替换成spring提供的
  • @Runwith
  • 3,告知spring的运行期,IOC是xml还是注解的
  • @ContextConfiguration() :
  • locations:指定xml文件位置
  • classes:指定注解类所在位置
全部评论

相关推荐

头像
05-22 20:17
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务