pom.xml是maven项目中的一个很重要的文件,很多依赖都在这个文件中配置。
pom.xml依赖的配置主要分为:
两大依赖:1.模块依赖;2.框架依赖
三个部分:1.对于项目本身模块的依赖;2:对于自己公司的封装包的依赖;3:对于第三方包的依赖。
(一)、Dao层的典型依赖-----和数据相关的依赖
1. spring-jdbc
1 <dependency> 2 <groupId>org.springframeworkgroupId> 3 <artifactId>spring-jdbcartifactId> 4 dependency>
2. spring-data-commons(分页...)
1 <dependency> 2 <groupId>org.springframework.datagroupId> 3 <artifactId>spring-data-commonsartifactId> 4 dependency>
3.mybatis( 公司包)
1 <dependency> 2 <groupId>com.xxxx.frameworkgroupId> 3 <artifactId>xxxx-mybatisartifactId> 4 dependency>
4.redis(公司包)
1 <dependency> 2 <groupId>com.vivo.frameworkgroupId> 3 <artifactId>vivo-redisartifactId> 4 dependency>
(二)、Service层的典型依赖:
Apache:
1. common-lang3----各种工具类(StringUtils...)
1 <dependency> 2 <groupId>org.apache.commonsgroupId> 3 <artifactId>commons-lang3artifactId> 4 dependency>
https://zhidao.baidu.com/question/587200456967870805.html
2.common-collections(集合工具类)
1 <dependency> 2 <groupId>commons-collectionsgroupId> 3 <artifactId>commons-collectionsartifactId> 4 dependency>
3. common-io(IO工具类)
1 <dependency> 2 <groupId>commons-iogroupId> 3 <artifactId>commons-ioartifactId> 4 dependency>
4. Json
4.1 json 三大组件:
1 <dependency> 2 <groupId>com.fasterxml.jackson.coregroupId> 3 <artifactId>jackson-coreartifactId> 4 dependency> 5 <dependency> 6 <groupId>com.fasterxml.jackson.coregroupId> 7 <artifactId>jackson-databindartifactId> 8 dependency> 9 <dependency> 10 <groupId>com.fasterxml.jackson.coregroupId> 11 <artifactId>jackson-annotationsartifactId> 12 dependency>
4.2 其他的json三方包---alibaba
1 <dependency> 2 <groupId>com.alibabagroupId> 3 <artifactId>fastjsonartifactId> 4 dependency>
5. 日志
1 2 <dependency> 3 <groupId>org.slf4jgroupId> 4 <artifactId>slf4j-apiartifactId> 5 dependency> 6 <dependency> 7 <groupId>log4jgroupId> 8 <artifactId>log4jartifactId> 9 dependency> 10 <dependency> 11 <groupId>org.slf4jgroupId> 12 <artifactId>slf4j-log4j12artifactId> 13 dependency> 14 15 16 <dependency> 17 <groupId>org.slf4jgroupId> 18 <artifactId>jcl-over-slf4jartifactId> 19 dependency> 20 21 22 <dependency> 23 <groupId>org.slf4jgroupId> 24 <artifactId>jul-to-slf4jartifactId> 25 dependency>
6.Spring(7大组件)
1 2 <dependency> 3 <groupId>org.springframeworkgroupId> 4 <artifactId>spring-coreartifactId> 5 dependency> 6 <dependency> 7 <groupId>org.springframeworkgroupId> 8 <artifactId>spring-beansartifactId> 9 dependency> 10 <dependency> 11 <groupId>org.springframeworkgroupId> 12 <artifactId>spring-contextartifactId> 13 dependency> 14 <dependency> 15 <groupId>org.springframeworkgroupId> 16 <artifactId>spring-context-supportartifactId> 17 dependency> 18 <dependency> 19 <groupId>org.springframeworkgroupId> 20 <artifactId>spring-aopartifactId> 21 dependency> 22 <dependency> 23 <groupId>org.springframeworkgroupId> 24 <artifactId>spring-aspectsartifactId> 25 dependency> 26 <dependency> 27 <groupId>org.springframeworkgroupId> 28 <artifactId>spring-expressionartifactId> 29 dependency> 30
7. xxxx-commons(公司框架--读写分离、多库多表....)
1 <dependency> 2 <groupId>com.xxxx.frameworkgroupId> 3 <artifactId>xxxx-commonsartifactId> 4 dependency>
8.commons-validator (通用验证系统)
1 <dependency> 2 <groupId>commons-validatorgroupId> 3 <artifactId>commons-validatorartifactId> 4 dependency>
9.dubbo(阿里巴巴的分布式框架)
1 <dependency> 2 <groupId>com.alibabagroupId> 3 <artifactId>dubboartifactId> 4 <exclusions> 5 <exclusion> 6 <artifactId>curator-clientartifactId> 7 <groupId>org.apache.curatorgroupId> 8 exclusion> 9 exclusions> 10 dependency>
10.curator-framework(Zookeeper客户端)
1 <dependency> 2 <groupId>org.apache.curatorgroupId> 3 <artifactId>curator-frameworkartifactId> 4 dependency>
11.Dao层的依赖(spring-jdbc/spring-data-commons/mybatis/redis)
1 <dependency> 2 <groupId>org.springframeworkgroupId> 3 <artifactId>spring-jdbcartifactId> 4 dependency> 5 6 <dependency> 7 <groupId>org.springframework.datagroupId> 8 <artifactId>spring-data-commonsartifactId> 9 dependency> 10 11 <dependency> 12 <groupId>com.vivo.frameworkgroupId> 13 <artifactId>vivo-mybatisartifactId> 14 dependency>
1 <dependency> 2 <groupId>com.vivo.frameworkgroupId> 3 <artifactId>vivo-redisartifactId> 4 dependency>
(三)、Web层的典型依赖:
1. 模块依赖对Service层的依赖
2.框架依赖
2.1 spring-web
1 <dependency> 2 <groupId>org.springframeworkgroupId> 3 <artifactId>spring-webartifactId> 4 dependency>
2.2 spring-webmvc
1 <dependency> 2 <groupId>org.springframeworkgroupId> 3 <artifactId>spring-webmvcartifactId> 4 dependency>
2.3 servlet-api(前端控制器DispacherServlet就是一个servlet)
1 <dependency> 2 <groupId>javax.servletgroupId> 3 <artifactId>servlet-apiartifactId> 4 <scope>providedscope>//如果不配置scope,会把jar包发布,会跟容器里的jar包冲突 5 dependency>
JSTL使用需要的两个包
2.4 jstl(java script tag language)
1 <dependency> 2 <groupId>jstlgroupId> 3 <artifactId>jstlartifactId> 4 dependency>
2.5 taglibs(标签库)
1 <dependency> 2 <groupId>taglibsgroupId> 3 <artifactId>standardartifactId> 4 dependency>
至此,Dao、Service、Web三个层的常用的依赖包就基本罗列完成,下面详细分析每个包.