1.直接基于spring framework开发自己的应用程序:

  1.1参考资料:

    Spring官网spring-framework.4.3.5.RELAESE的Reference Documentation的下面的章节

          

  1.2学习心得

        • spring framework是一个模块化的工程,该框架被划分成大约20个模块,用户可以根据自己的项目想要完成的功能灵活选用spring framework的若干功能模块集成到自己的项目中,并不需要集成spring framework中所有模块到自己的项目中。(关于你的项目中应该选用哪些模块,“本文1.1小节中提及的资料”中有列举一些例子,开发者可以参照该reference documentation中列举的这些例子来选取自己的project所要集成的模块)
        • 由于spring framework是支持maven的,所以在自己的项目中集成spring framework的若干模块时,可以使用maven。
            • 如何配置maven的pom.xml来集成spring framework的若干module,请参见本文1.1小节中提及的参考资料    
            • 也可以配置pom.xml使得不是从maven中央仓库而是从spring maven lib下载相关jar包到本地仓库,具体配置方法参见请参见本文1.1小节中提及的参考资料
            • Maven "Bill Of Materials" Dependency,通过BOM管理要引入的各个模块的版本号,避免不同jar包之间发生版本冲突问题,具体配置方法参见请参见本文1.1小节中提及的参考资料
        • spring framework也会依赖很多三方库、三方插件等,但是这些依赖并不是强制性依赖关系,开发者在自己的project中引用spring framework的若干模块时,可以不引入spring framework所依赖的其他三方插件,除了logging插件。也就是说,开发者在自己的project中使用spring framework时,必须考虑引入spring framework所依赖的logging插件,也只需要考虑这一个插件,因为it is the only mandatory【强制性的】 external dependency of spring framework。
            • spring framework本身所集成的logging插件是commons-logging,但是这个logging插件并不是很好用,所以一般需要开发者将commons-logging替换成其他日志管理工具,如Log4J、SLF4J
            • 要想替换掉spring framework各个模块中的commons-logging,只需要替换掉spring-core module中的common-logging即可,因为spring-core是spring framework中唯一一个显示依赖commons-logging的模块,而spring framework的其他模块都是基于spring-core发展而来的,其他模块都是通过spring-core获取commons-logging的功能的
            • 如何将spring framework的commons-logging替换成其他日志管理工具如 Log4J、SLF4J,参见本文第1.2节中提到的参考资料
                • SLF4J provides bindings to many common logging frameworks, SLF4J is bridges between other logging frameworks and itself      

  1.3 实际操作

      step1,在myeclipse中创建了一个maven web project,   教程

      step2,编写该project的pom.xml,集成spring framework的spring-context模块

      step3,修改pom.xml,修改spring framework所以来的logging插件,将commons-logging改成其他logging插件,如 Log4J

        • step3.1,exclude the existing commons-logging from Spring Framework的spring-core module
        • step3.2,You need to supply 4 dependencies: the bridge, the SLF4J API, the binding to Log4J, and the Log4J implementation itself.
            • the bridge,SLF4J-JCL bridge.在spring framework和SLF4J之间建立起桥梁,这样一来, logging calls from within Spring will be translated into logging calls to the SLF4J API,
            • the SLF4J API,
            • the binding to Log4J,
            • the Log4J implementation itself.    

          

        • pom.xml
        • <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>bupt.jinmensuyin</groupId>
          <artifactId>TestSpring</artifactId>
          <packaging>war</packaging>
          <version>0.0.1-SNAPSHOT</version>
          <name>TestSpring Maven Webapp</name>
          <url>http://maven.apache.org</url>
          <dependencyManagement>
          <dependencies>
          <!-- BOM:bill of materials,其实就是一个列表,该列表中描述了spring framework各个模块及其唯一的版本号,
          引入BOM之后,下面再引入spring framework的各个module时,就可以省略<version>标签,maven会自动查询BOM来
          得知应该引入该module的哪个版本 -->
          <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-framework-bom</artifactId>
          <version>4.3.5.RELEASE</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          </dependencies>
          </dependencyManagement>
          <dependencies>
          <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
          </dependency>
          <!-- spring framework的spring-context模块提供依赖注入功能 -->
          <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <scope>runtime</scope>
          </dependency>
          <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <exclusions>
          <!-- exclusion:排除
          这里的配置将commons-logging这个三方日志库文件从spring-core模块中排除出去,
          这样一来spring framework的所有模块都没有了logging插件
          (为什么Exclude the dependency from the spring-core module就等于从整个spring framework
          的所有module中都排除了commons-logging?
          答:因为the spring-core module is the only module that explicitly显式地 depends on
          commons-logging,spring framework的其他module都是基于spring-core的,
          其他module通过spring-core获得commons-logging提供的功能)) -->
          <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          </exclusion>
          </exclusions>
          </dependency>
          <!-- 排除了spring framework中本身带有的commons-logging之后,要继承其他的三方log插件来管理日志
          You need to supply 4 dependencies: the bridge, the SLF4J API,
          the binding to Log4J, and the Log4J implementation itself.-->
          <!-- 在spring framework和SLF4J之间架起桥梁,使得logging calls from within Spring
          will be translated into logging calls to the SLF4J API, -->
          <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>jcl-over-slf4j</artifactId>
          <version>1.5.8</version>
          </dependency>
          <!-- the SLF4J API, -->
          <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
          <version>1.5.8</version>
          </dependency>
          <!-- 在SLF4J和Log4J之间架起桥梁 -->
          <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
          <version>1.5.8</version>
          </dependency>
          <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.12</version>
          </dependency>
          </dependencies>
          <build>
          <finalName>TestSpring</finalName>
          </build>
          <repositories>
          <!-- 添加了如下配置之后,就不从maven中央仓库下载相关jar包,而是从如下url下载相关jar包
          到maven本地仓库 -->
          <repository>
          <id>io.spring.repo.maven.release</id>
          <url>http://repo.spring.io/release/</url>
          <snapshots><enabled>false</enabled></snapshots>
          </repository>
          </repositories>
          </project>

                          

Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->使用Spring Framework开发自己的应用程序的更多相关文章

  1. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->关于spring framework中的beans

    Spring framework中的beans 1.概述 bean其实就是各个类实例化后的对象,即objects spring framework的IOC容器所管理的基本单元就是bean spring ...

  2. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->使用spring framework的IoC容器功能----->方法一:使用XML文件定义beans之间的依赖注入关系

    XML-based configuration metadata(使用XML文件定义beans之间的依赖注入关系) 第一部分 编程思路概述 step1,在XML文件中定义各个bean之间的依赖关系. ...

  3. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework中web相关的知识(概述)

    Spring Framework中web相关的知识 1.概述: 参考资料:官网documentation中第22小节内容 关于spring web mvc:  spring framework中拥有自 ...

  4. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework中的spring web MVC模块

    spring framework中的spring web MVC模块 1.概述 spring web mvc是spring框架中的一个模块 spring web mvc实现了web的MVC架构模式,可 ...

  5. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework的依赖注入和控制反转

    Dependency Injection and Inversion of Control 1.概述: 1.1相关概念 bean:由IoC容器所管理的对象,也即各个类实例化所得对象都叫做bean 控制 ...

  6. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework概述

    Spring Framework是什么? it is a potential one-stop-shop for building your enterprise-ready applications ...

  7. Spring Framework------>version4.3.5----->Reference学习心得----->总结

    1.Spring Framework概述: 有很多可用版本,网址http://projects.spring.io/spring-framework/       2.Spring Framework ...

  8. Spring Framework 4.3.22.RELEASE Reference文档目录

    <Spring Framework Reference Documentation 4.3.22.RELEASE> https://docs.spring.io/spring/docs/4 ...

  9. Springfox Reference Documentation

    1. Introduction The Springfox suite of java libraries are all about automating the generation of mac ...

随机推荐

  1. [翻译练习]密码学1小时入门 (Everything you need to know about cryptography in 1 hour)

    原文:http://www.daemonology.net/papers/crypto1hr.pdf   [密码学简介]   很多人都误用了密码学   一般可归为三类: 1. 愚蠢 比如Google ...

  2. hive导入数据

    替换分隔符为\ sed -i 's/\t/\x1/g;s/;/\x1/g' test1.txt gz压缩 gzip -r test1.txt 查看文件 hdfs dfs -ls /hive/wareh ...

  3. 共享onload事件

    在做前端工作中,我们想要设置某个函数prepare,让它在网页加载完毕后执行,会触发一个onload事件,这个事件与windows对象相关联,必须把prepare函数绑定到这个时间上,语法如下:win ...

  4. BIO,NIO,AIO

    同步阻塞IO(JAVA BIO):     同步并阻塞,服务器实现模式为一个连接一个线程,即客户端有连接请求时服务器端就需要启动一个线程进行处理,如果这个连接不做任何事情会造成不必要的线程开销,当然可 ...

  5. webApi上传下载文件

    上传文件通过webApi html端调用时包含(form提交包含 enctype="multipart/form-data",才可以启作用获取到文件) public class U ...

  6. 答:SQLServer DBA 三十问之三:有哪些操作会使用到TempDB;如果TempDB异常变大,可能的原因是什么,该如何处理

    3. 有哪些操作会使用到TempDB:如果TempDB异常变大,可能的原因是什么,该如何处理: tempdb的用途:1)存储专用和全局临时变量,不考虑数据库上下文: 2)与Order by 子句,游标 ...

  7. dell omsa 监控,Nrpe信号量泄露

    ipcs -s | awk '/nrpe/ {print "ipcrm -s ",$2} ' | sh /etc/init.d/dataeng stop /etc/init.d/d ...

  8. 云时代的分布式数据库:阿里分布式数据库服务DRDS

    发表于2015-07-15 21:47| 10943次阅读| 来源<程序员>杂志| 27 条评论| 作者王晶昱 <程序员>杂志数据库DRDS分布式沈询 摘要:伴随着系统性能.成 ...

  9. spring 事务问题

    今天碰到一个奇怪的问题,在service中执行方法,调用了两次dao,前面是save,在save后面抛错,竟然没回滚,难道不是一个事务? 后来网上查资料,发现spring的事务回滚必须是运行时异常Ru ...

  10. Foundation ----->NSNumber

    /*--------------------NSNumber--------------------*/     //包装基本数据类型          //1.创建number对象     //12 ...