临时抱佛脚之Spring学习笔记

       好久都没有碰过spring的知识了,最近心血来潮,希望能好好看看。当然啦,时间也不是很充分,当然,我个人而言也确实没有太多的精力,周六日还有一些比较棘手的事情,只能抽自己还算清楚的时候写点代码,做下总结了。

      首先是以java project的方式来运行spring程序,其实算是测试一下是 怎样使用spring容器吧,我是通过看视频来学习 的,讲得很细致,操作也很清晰 明了。我很郁闷的是spring的jar包和源码包在官方网站竟然找不到下载的地方,而且在 其他地方也找不到比较好的资源,没有办法,就将就着使用到了哪个包就找哪个包,然后引用到程序中。配置文件的模版大致如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/tx hsttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
 default-autowire="byName" default-lazy-init="true">
 </beans>
配置文件大多数 情况下是放在类路径下,就是src目录下。加载配置文件的方式也有两种,一种是在类路径下寻找配置 文件,当然这也是最常用的,其调用方法 为:

ApplicationContext cxt=new ClassPathXmlApplicationContext(new String[]{"beans.xxml"});其中配置文件可以 是一个,也可以是多个。还有一种方式是在文件系统路径下去寻找,这要用到绝对路径,考虑到程序的移植问题,这样方法可操作性不强。(待续)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值