(六)Maven之pom.xml文件简单表明

4)
artifactId定义项目中的有个别模块名称,如若只有二个模块那正是项目标名称。

1) project是持有pom.xml的根成分,并且在内部定义了命名空间和xsd成分。

 

   大家切实来探视这一个结构:

 

   <dependency>

     <!—首要用以破除传递性注重–>

         <groupId>…</groupId>

 

         <artifactId>…</artifactId>

7)
dependencies成分底下正是投入注重包的地点,那么大家从何地查询注重包呢,可以查询的地点比较多,作者付出二个豪门用得比较多的仓库:http://mvnrepository.com

2) modelVersion 当前pom模型的版本。

因而前边几部分知识,我们对maven已经有了开端的回忆,就像是Make的Makefile、Ant的build.xml一样,Maven项指标主干是pom.xml。POM(Project
Object
Model,项目对象模型)定义了品种的中坚音讯,用于描述项目什么创设,申明注重,等等。大家来看望maven中pom.xml文件重庆大学标签的情致及其用法,来看一下pom.xml文件的布局:

可爱博主:AlanLee

 

3) groupId定义当前maven项目隶属的实在项目,并会基于那给项目确立包结构。

     </exclusions>

       </exclusion>

  1 <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/xsd/maven-4.0.0.xsd">
  2     <modelVersion>4.0.0</modelVersion>
  3 
  4     <groupId>com.uidp</groupId>
  5     <artifactId>UidpParent</artifactId>
  6     <version>0.0.1-SNAPSHOT</version>
  7     <packaging>pom</packaging>
  8 
  9     <!--当前项目的全称(名称)-->
 10     <name>UidpParent</name>
 11     <!--当前项目的主页的URL-->
 12     <url>http://maven.apache.org</url>
 13 
 14     <!--配置常用属性或定义一系列版本号-->
 15     <properties>
 16         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 17 
 18         <repository-url>http://192.168.0.70:8081/content/groups/public/</repository-url>
 19 
 20         <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
 21         <maven-war-plugin.version>2.4</maven-war-plugin.version>
 22         <maven-javadoc-plugin.version>2.9.1</maven-javadoc-plugin.version>
 23         <maven-release-plugin.version>2.4.1</maven-release-plugin.version>
 24         <maven-deploy-plugin.version>2.7</maven-deploy-plugin.version>
 25 
 26 
 27 
 28         <junit.version>4.11</junit.version>
 29         <oracle.version>10.2.0.4</oracle.version>
 30         <springframework.version>3.2.8.RELEASE</springframework.version>
 31         <mybatis.version>3.2.2</mybatis.version>
 32         <mybatis-spring.version>1.2.0</mybatis-spring.version>
 33         <mysql-driver.version>5.1.25</mysql-driver.version>
 34         <aspectjweaver.version>1.7.3</aspectjweaver.version>
 35 
 36         <commons-dbcp.version>1.4</commons-dbcp.version>
 37         <commons-pool.version>1.5.5</commons-pool.version>
 38         <commons-fileupload.version>1.2.2</commons-fileupload.version>
 39 
 40         <log4j.version>1.2.17</log4j.version>
 41         <slf4j-api.version>1.7.5</slf4j-api.version>
 42         <slf4j-log4j12.version>1.7.5</slf4j-log4j12.version>
 43 
 44         <freemarker.version>2.3.19</freemarker.version>
 45 
 46         <jackson-core.version>2.5.0</jackson-core.version>
 47         <jackson-mapper-asl.version>1.9.7</jackson-mapper-asl.version>
 48 
 49         <javax.servlet-api.version>3.0.1</javax.servlet-api.version>
 50         <jsp-api.version>2.2</jsp-api.version>
 51         <kryo.version>1.04</kryo.version>
 52         <snakeyaml.version>1.8</snakeyaml.version>
 53         <jedis.version>2.0.0</jedis.version>
 54         <commons-lang.version>2.6</commons-lang.version>
 55 
 56 
 57         <mockito-core.version>1.8.5</mockito-core.version>
 58         <powermock-core.version>1.4.9</powermock-core.version>
 59         <powermock-api-mockito.version>1.4.9</powermock-api-mockito.version>
 60         <powermock-module-junit4.version>1.4.9</powermock-module-junit4.version>
 61 
 62 
 63     </properties>
 64 
 65     <!--依赖管理-->
 66     <dependencyManagement>
 67         <dependencies>
 68 
 69             <dependency>
 70                 <groupId>junit</groupId>
 71                 <artifactId>junit</artifactId>
 72                 <version>${junit.version}</version>
 73                 <scope>test</scope>
 74             </dependency>
 75 
 76             <!-- spring jar begin -->
 77             <dependency>
 78                 <groupId>org.springframework</groupId>
 79                 <artifactId>spring-web</artifactId>
 80                 <version>${springframework.version}</version>
 81             </dependency>
 82 
 83             <dependency>
 84                 <groupId>org.springframework</groupId>
 85                 <artifactId>spring-webmvc</artifactId>
 86                 <version>${springframework.version}</version>
 87             </dependency>
 88 
 89             <dependency>
 90                 <groupId>org.springframework</groupId>
 91                 <artifactId>spring-beans</artifactId>
 92                 <version>${springframework.version}</version>
 93             </dependency>
 94 
 95             <dependency>
 96                 <groupId>org.springframework</groupId>
 97                 <artifactId>spring-context</artifactId>
 98                 <version>${springframework.version}</version>
 99             </dependency>
100 
101             <dependency>
102                 <groupId>org.springframework</groupId>
103                 <artifactId>spring-context-support</artifactId>
104                 <version>${springframework.version}</version>
105             </dependency>
106 
107             <dependency>
108                 <groupId>org.springframework</groupId>
109                 <artifactId>spring-core</artifactId>
110                 <version>${springframework.version}</version>
111             </dependency>
112 
113             <dependency>
114                 <groupId>org.springframework</groupId>
115                 <artifactId>spring-jdbc</artifactId>
116                 <version>${springframework.version}</version>
117             </dependency>
118 
119             <dependency>
120                 <groupId>org.springframework</groupId>
121                 <artifactId>spring-tx</artifactId>
122                 <version>${springframework.version}</version>
123             </dependency>
124 
125             <dependency>
126                 <groupId>org.springframework</groupId>
127                 <artifactId>spring-test</artifactId>
128                 <version>${springframework.version}</version>
129             </dependency>
130 
131             <dependency>
132                 <groupId>org.springframework</groupId>
133                 <artifactId>spring-expression</artifactId>
134                 <version>${springframework.version}</version>
135             </dependency>
136 
137             <dependency>
138                 <groupId>org.springframework</groupId>
139                 <artifactId>spring-aop</artifactId>
140                 <version>${springframework.version}</version>
141             </dependency>
142             <!-- spring jar end -->
143 
144             <dependency>
145                 <groupId>org.mybatis</groupId>
146                 <artifactId>mybatis</artifactId>
147                 <version>${mybatis.version}</version>
148             </dependency>
149 
150             <dependency>
151                 <groupId>org.mybatis</groupId>
152                 <artifactId>mybatis-spring</artifactId>
153                 <version>${mybatis-spring.version}</version>
154             </dependency>
155 
156             <dependency>
157                 <groupId>mysql</groupId>
158                 <artifactId>mysql-connector-java</artifactId>
159                 <version>${mysql-driver.version}</version>
160             </dependency>
161 
162             <dependency>
163                 <groupId>com.oracle</groupId>
164                 <artifactId>ojdbc14</artifactId>
165                 <version>${oracle.version}</version>
166             </dependency>
167 
168             <dependency>
169                 <groupId>org.aspectj</groupId>
170                 <artifactId>aspectjweaver</artifactId>
171                 <version>${aspectjweaver.version}</version>
172             </dependency>
173 
174 
175             <dependency>
176                 <groupId>commons-dbcp</groupId>
177                 <artifactId>commons-dbcp</artifactId>
178                 <version>${commons-dbcp.version}</version>
179             </dependency>
180             <dependency>
181                 <groupId>commons-pool</groupId>
182                 <artifactId>commons-pool</artifactId>
183                 <version>${commons-pool.version}</version>
184             </dependency>
185             <dependency>
186                 <groupId>commons-fileupload</groupId>
187                 <artifactId>commons-fileupload</artifactId>
188                 <version>${commons-fileupload.version}</version>
189             </dependency>
190 
191 
192             <!-- log jar -->
193             <dependency>
194                 <groupId>log4j</groupId>
195                 <artifactId>log4j</artifactId>
196                 <version>${log4j.version}</version>
197             </dependency>
198             <dependency>
199                 <groupId>org.slf4j</groupId>
200                 <artifactId>slf4j-api</artifactId>
201                 <version>${slf4j-api.version}</version>
202             </dependency>
203             <dependency>
204                 <groupId>org.slf4j</groupId>
205                 <artifactId>slf4j-log4j12</artifactId>
206                 <version>${slf4j-log4j12.version}</version>
207             </dependency>
208 
209             <!-- freemarker -->
210             <dependency>
211                 <groupId>org.freemarker</groupId>
212                 <artifactId>freemarker</artifactId>
213                 <version>${freemarker.version}</version>
214             </dependency>
215 
216 
217             <!-- jackson -->
218             <dependency>
219                 <groupId>com.fasterxml.jackson.core</groupId>
220                 <artifactId>jackson-core</artifactId>
221                 <version>${jackson-core.version}</version>
222             </dependency>
223             <dependency>
224                 <groupId>org.codehaus.jackson</groupId>
225                 <artifactId>jackson-mapper-asl</artifactId>
226                 <version>${jackson-mapper-asl.version}</version>
227             </dependency>
228 
229             <dependency>
230                 <groupId>javax.servlet</groupId>
231                 <artifactId>javax.servlet-api</artifactId>
232                 <version>${javax.servlet-api.version}</version>
233                 <scope>provided</scope>
234             </dependency>
235 
236             <dependency>
237                 <groupId>javax.servlet.jsp</groupId>
238                 <artifactId>jsp-api</artifactId>
239                 <version>${jsp-api.version}</version>
240                 <scope>provided</scope>
241             </dependency>
242 
243             <dependency>
244                 <groupId>com.googlecode</groupId>
245                 <artifactId>kryo</artifactId>
246                 <version>${kryo.version}</version>
247             </dependency>
248 
249             <dependency>
250                 <groupId>org.yaml</groupId>
251                 <artifactId>snakeyaml</artifactId>
252                 <version>${snakeyaml.version}</version>
253             </dependency>
254 
255             <dependency>
256                 <groupId>redis.clients</groupId>
257                 <artifactId>jedis</artifactId>
258                 <version>${jedis.version}</version>
259             </dependency>
260 
261             <dependency>
262                 <groupId>commons-lang</groupId>
263                 <artifactId>commons-lang</artifactId>
264                 <version>${commons-lang.version}</version>
265             </dependency>
266 
267 
268             <dependency>
269                 <groupId>org.mockito</groupId>
270                 <artifactId>mockito-core</artifactId>
271                 <version>${mockito-core.version}</version>
272                 <scope>test</scope>
273             </dependency>
274 
275             <dependency>
276                 <groupId>org.powermock</groupId>
277                 <artifactId>powermock-core</artifactId>
278                 <version>${powermock-core.version}</version>
279                 <scope>test</scope>
280             </dependency>
281 
282             <dependency>
283                 <groupId>org.powermock</groupId>
284                 <artifactId>powermock-api-mockito</artifactId>
285                 <version>${powermock-api-mockito.version}</version>
286                 <scope>test</scope>
287             </dependency>
288 
289             <dependency>
290                 <groupId>org.powermock</groupId>
291                 <artifactId>powermock-module-junit4</artifactId>
292                 <version>${powermock-module-junit4.version}</version>
293                 <scope>test</scope>
294             </dependency>
295 
296 
297         </dependencies>
298     </dependencyManagement>
299     
300     <distributionManagement>
301         <repository>
302             <id>releases</id>
303             <name>public</name>
304             <url>http://59.50.95.66:8081/nexus/content/repositories/releases</url>
305         </repository>
306         <snapshotRepository>
307             <id>snapshots</id>
308             <name>Snapshots</name>
309             <url>http://59.50.95.66:8081/nexus/content/repositories/snapshots</url>
310         </snapshotRepository>
311     </distributionManagement>
312     
313     
314     <!--构建管理-->
315     <build>
316         <plugins>
317 
318             <plugin>
319                 <groupId>org.apache.maven.plugins</groupId>
320                 <artifactId>maven-compiler-plugin</artifactId>
321                 <version>${maven-compiler-plugin.version}</version>
322                 <configuration>
323                     <source>1.7</source> <!-- 源代码使用的开发版本 -->
324                     <target>1.7</target> <!-- 需要生成的目标class文件的编译版本 -->
325                 </configuration>
326             </plugin>
327 
328             <plugin>
329                 <groupId>org.apache.maven.plugins</groupId>
330                 <artifactId>maven-javadoc-plugin</artifactId>
331                 <version>${maven-javadoc-plugin.version}</version>
332             </plugin>
333 
334 
335             <plugin>
336                 <groupId>org.apache.maven.plugins</groupId>
337                 <artifactId>maven-release-plugin</artifactId>
338                 <version>${maven-release-plugin.version}</version>
339             </plugin>
340 
341             <plugin>
342                 <groupId>org.apache.maven.plugins</groupId>
343                 <artifactId>maven-deploy-plugin</artifactId>
344                 <version>${maven-deploy-plugin.version}</version>
345                 <configuration>
346                     <updateReleaseInfo>true</updateReleaseInfo>
347                 </configuration>
348             </plugin>
349 
350         </plugins>
351     </build>
352 
353 
354     <pluginRepositories>
355         <pluginRepository>
356             <id>nexus</id>
357             <name>nexus</name>
358             <url>${repository-url}</url>
359             <releases>
360                 <enabled>true</enabled>
361             </releases>
362             <snapshots>
363                 <enabled>true</enabled>
364             </snapshots>
365         </pluginRepository>
366     </pluginRepositories>
367 
368     
369 </project>

 

 

     <type>依赖类型</type>

     <groupId>实际项目</groupId>

   (2)optional标记正视是不是可选

不曾其他实际的Java代码,大家能够定义三个Maven项目标POM,那反映了Maven的一大亮点,它能让项目对象模型最大程度地与实际代码相独立,我们得以称为解耦。那在非常的大程度上制止了Java代码和POM代码的相互影响。只要我们定义的POM稳定后,经常的Java代码开发工作中挑广陵不会涉嫌到POM的修改。

     <artifactId>模块</artifactId>

Maven是因而groupId、artifactId、version这三好像于坐标的要从来明确唯一性的,由此那多个成分对于每一种注重庆大学多是必须的,前面会详细介绍重视、聚合、继承等知识点。

   (1)type表明正视的品类

     <version>版本</version>

     <scope>信赖范围</scope>

正文来源和讯,欢迎我们参预果壳网。

     <optional>正视是或不是可选</optional>

   (3)exclusions 用来排斥传递重视

博客地址:http://www.cnblogs.com/AlanLee

5) version 定义maven项目当前所处的版本号,暗中同意0.0.1-SNAPSHOT为快速照相版本。

8)
每一种dependency都以3个依靠包,正视包也正是在dependency里面定义种种重视包的坐标,这样maven就会从网上下载注重包到你本地仓库中,有所不相同的是dependency成分包括了三个子成分,这么些就是对maven生命周期的3个验证,当然除了下面多个子元素外,还含有多少个别的的成分。

咱俩得以见到maven的pom.xml文件结构相当清晰,把项目创制好后,我们大多是在dependencies成分下添加一些子成分及plugins元素下添加一些插件,上面大家来介绍一下相继要素的含义。

6) packaging定义maven项目标打包格局,能够是jar包、war包、pom。

     <exclusions>

   </dependency>

       <exclusion>

相关文章