第一篇博客,spring配置文件

来源:互联网 发布:中银证券交易软件 编辑:程序博客网 时间:2024/05/16 05:35
    以前自己学习的时候搭建过SSH框架,但是现在到公司了工作了那么久,很多东西都忘记了,而且当时习惯不好,没有做笔记,所有现在有空闲的时间,决定 写下博客,记录自己的学习过程,也为将来查找资料方便.

现在开始吧,最基础的,在eclipse里面新建一个maven项目, 进spring官网http://projects.spring.io/spring-framework/复制如下代码,直接拷贝到maven项目中的pom.xml文件中,
这里写图片描述
如图: 这里写图片描述
稍等一会儿,maven会直接把spring的jar包download下来,这只是核心的jar,如果需要其他的,还要到官网上面找,这里不再累述.

接下来,在resources文件夹下面新建一个xml文件,名称随便取,一般叫applicationContext.xml, 然后复制以下代码:

<?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:jdbc="http://www.springframework.org/schema/jdbc"      xmlns:jee="http://www.springframework.org/schema/jee"     xmlns:tx="http://www.springframework.org/schema/tx"    xmlns:aop="http://www.springframework.org/schema/aop"     xmlns:mvc="http://www.springframework.org/schema/mvc"    xmlns:util="http://www.springframework.org/schema/util"    xmlns:jpa="http://www.springframework.org/schema/data/jpa"    xsi:schemaLocation="        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"</beans>

具体的.xsd版本,根据你所依赖的jar包更改即可。

0 0
原创粉丝点击