【Spring.Framework】依赖管理, Logging
来源:互联网 发布:注册淘宝需要什么条件 编辑:程序博客网 时间:2024/05/17 08:42
依赖管理
Maven Dependency Management
Maven "Bill of Materials" Dependency:
使用Spring的不同模块时,可能由于使用不同版本的Spring模块引入同一第三方库的不同版本。
Maven 通过 “BOM” 来解决这个问题:在dependencyManagement中引入spring-framework-bom来确保所有的spring模块都使用统一的版本:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-framework-bom</artifactId> <version>4.1.1.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies></dependencyManagement>
此时,所有使用的spring模块dependency都不需要在声明version属性。例如:
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency><dependencies>
(只有当外层的dependency元素中没有指明版本信息时,dependencyManagement中的dependencies元素才会起作用)。
Logging
Spring默认使用Jakarta Commons Logging API(JCL)作为logging framework。
不使用Commons Logging
从spring-core模块中移除掉commons-logging,
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions></dependency>
移除commons-logging后,我们需要添加一个替代的logging framework。
使用SLF4J
SLF4J可以绑定到许多的logging框架,同时也提供了反向操作,桥接其他的logging 框架到SLF4J.
因此,在Spring中使用SLF4J需要使用SLF4J-JCL bridge去替代commons-logging依赖,Spring中的logging调用将会转换成SLF4J API的调用。
需要提供4个dependencies(同时exclude commons-logging):the bridge, the slf4j api, the binding to log4j, the log4j implementation:
<!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.5.8</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.8</version> </dependency> <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.14</version> </dependency>
- 【Spring.Framework】依赖管理, Logging
- Spring Framework Logging
- Spring FrameWork 总结-- 依赖
- Spring Framework 注入依赖
- Spring -- 依赖管理
- Spring依赖配置化管理
- Spring Boot + Gradle 依赖管理
- GWT - Logging Framework
- 采用Spring管理Bean和依赖注入
- Spring的模块化可依赖管理
- 采用Spring管理Bean和依赖注入
- 采用Spring管理Bean和依赖注入
- 采用Spring管理Bean和依赖注入
- Spring-boot +Gradle依赖管理+Mybatis 配置文件
- spring framework 3.2.4 各组件依赖包列表
- POCO库的Logging framework
- POCO库的Logging framework
- Logging and Spring AOP
- pat 1006
- Swift基础--ijkplayer编译
- struts2如何完成文件的上传
- Xcode及Mac快捷键大全
- ContentProvider(内容提供者)用法详解
- 【Spring.Framework】依赖管理, Logging
- hdu-oj 2516 取石子游戏 ( 博弈)
- git 删除已经 add 的文件
- JAVA设计模式之 抽象工厂模式【Abstract Factory Pattern】
- Android使用selector自定义按钮
- 网页上不允许复制怎么办?
- 微信oauth网页授权获取用户基本信息
- Hibernate如何实现分页
- 关于学习过程中走过的弯路