zoukankan      html  css  js  c++  java
  • Maven的pom实例

    该pom中包含了一些我认为会需要的东西,并且加了注释。可以根据需求适当删减。

     包含了spring-mvc , junit,hibernate验证,json,apache-commons组件

    还有 complier,cargo,surefire,jetty插件

      1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
      3     http://maven.apache.org/maven-v4_0_0.xsd">
      4     
      5     <!-- 下面7个设置就不用复制了,每个项目都不一样的 -->
      6     <modelVersion>4.0.0</modelVersion>
      7     <groupId>com.suyin</groupId>
      8     <artifactId>weixin</artifactId>
      9     <packaging>war</packaging>
     10     <version>0.0.1-SNAPSHOT</version>
     11     <name>weixin Maven Webapp</name>
     12     <url>http://maven.apache.org</url>
     13 
     14     <properties>
     15         <spring-version>4.0.6.RELEASE</spring-version>
     16         <junit-version>4.9</junit-version>
     17         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     18     </properties>
     19 
     20     <!-- 其实吧,如果你在ecplise中查看这个pom的继承树,你会发现好多都是重复的,完全可以不写:比如 spring-core,任何一个spring组件 -->
     21     <!-- 都依赖这个组件,并且也声明这个依赖啊,那么其实我们在这个pom中根本不必显式声明依赖 spring-core,Maven会自动帮我们处理这种依赖传递的。 -->
     22     <!-- 可是显式声明不是显得清楚明白一点么 -->
     23     <dependencies>
     24         <!--这个包要有,要不然在Controller中连HttpServletRequest都没法依赖了,不过在实际环境中容器会提供所以scope是provided -->
     25         <!-- 当然如果不是web项目那就肯定不需要了^_^ -->
     26         <dependency>
     27             <groupId>javax.servlet</groupId>
     28             <artifactId>javax.servlet-api</artifactId>
     29             <version>3.0.1</version>
     30             <scope>provided</scope>
     31         </dependency>
     32 
     33         <!-- 这个包未必要有,在jsp中,如果要写 out.print("xxx"); 那么如果没有这个包会发现key assistant根本没用了 -->
     34         <!-- 因为 out就是 javax.servlet.jsp.JspWriter的对象,而这个类就在这个包里面 -->
     35         <!-- 当然如果压根就没想过这么写,也可以不要这个组件 -->
     36         <dependency>
     37             <groupId>javax.servlet.jsp</groupId>
     38             <artifactId>jsp-api</artifactId>
     39             <version>2.2.1-b03</version>
     40             <scope>provided</scope>
     41         </dependency>
     42 
     43         <!-- spring 核心组件 开始 -->
     44         <dependency>
     45             <groupId>org.springframework</groupId>
     46             <artifactId>spring-core</artifactId>
     47             <version>${spring-version}</version>
     48         </dependency>
     49         <dependency>
     50             <groupId>org.springframework</groupId>
     51             <artifactId>spring-beans</artifactId>
     52             <version>${spring-version}</version>
     53         </dependency>
     54         <dependency>
     55             <groupId>org.springframework</groupId>
     56             <artifactId>spring-context</artifactId>
     57             <version>${spring-version}</version>
     58         </dependency>
     59         <dependency>
     60             <groupId>org.springframework</groupId>
     61             <artifactId>spring-context-support</artifactId>
     62             <version>${spring-version}</version>
     63         </dependency>
     64 
     65         <!-- spring expression是spring扩展el表达式的一个组件(SpEL) -->
     66         <!-- 一个最简单的应用使用cache时描述生成key的策略 -->
     67         <!-- 如有注解:@Cacheable(value="peoplecache",key="#root.method.name") -->
     68         <!-- 如果不需要用SpEL,就不要加这个组件了 -->
     69         <dependency>
     70             <groupId>org.springframework</groupId>
     71             <artifactId>spring-expression</artifactId>
     72             <version>${spring-version}</version>
     73         </dependency>
     74         <!-- spring 核心组件结束 -->
     75 
     76         <!-- spring web组件开始(看名字就知道要使用spring mvc的必须组件了) -->
     77         <dependency>
     78             <groupId>org.springframework</groupId>
     79             <artifactId>spring-web</artifactId>
     80             <version>${spring-version}</version>
     81         </dependency>
     82         <dependency>
     83             <groupId>org.springframework</groupId>
     84             <artifactId>spring-webmvc</artifactId>
     85             <version>${spring-version}</version>
     86         </dependency>
     87         <!-- spring web组件结束 -->
     88 
     89         <!-- aop(尽管不是十分清楚,但是如果要在xml中配置事务(声明性事务配置),我觉得就必须有这个组件;) -->
     90         <dependency>
     91             <groupId>org.springframework</groupId>
     92             <artifactId>spring-aop</artifactId>
     93             <version>${spring-version}</version>
     94         </dependency>
     95 
     96         <!-- 这里提供了对于AspectJ的整合,其实AspectJ是与spring-aop差不多但是可能功能多一点的框架 -->
     97         <!-- 一般情况下spring-aop就足够了,所以一般情况下也不需要这个组件 -->
     98         <dependency>
     99             <groupId>org.springframework</groupId>
    100             <artifactId>spring-aspects</artifactId>
    101             <version>${spring-version}</version>
    102         </dependency>
    103 
    104         <!-- spring数据层,没啥说的,当然如果用其他的jdbc那就可以不要这个组件了 -->
    105         <dependency>
    106             <groupId>org.springframework</groupId>
    107             <artifactId>spring-jdbc</artifactId>
    108             <version>${spring-version}</version>
    109         </dependency>
    110         <!-- 提供事务管理,没啥说的 -->
    111         <dependency>
    112             <groupId>org.springframework</groupId>
    113             <artifactId>spring-tx</artifactId>
    114             <version>${spring-version}</version>
    115         </dependency>
    116 
    117         <!-- 提过对junit和testng的支持,测试肯定要的 -->
    118         <dependency>
    119             <groupId>org.springframework</groupId>
    120             <artifactId>spring-test</artifactId>
    121             <version>${spring-version}</version>
    122             <scope>test</scope>
    123         </dependency>
    124 
    125         <!-- spring 不常用组件 开始 -->
    126         <!-- 估计随着HTML5的发展,这个组件会变得常用 -->
    127         <dependency>
    128             <groupId>org.springframework</groupId>
    129             <artifactId>spring-websocket</artifactId>
    130             <version>${spring-version}</version>
    131         </dependency>
    132 
    133         <!-- 这个组件提供对STOMP协议的支持,说实话从来没用过这个协议 -->
    134         <dependency>
    135             <groupId>org.springframework</groupId>
    136             <artifactId>spring-messaging</artifactId>
    137             <version>${spring-version}</version>
    138         </dependency>
    139 
    140         <!-- 提供了对各个容器的扩展,似乎并不太需要 -->
    141         <dependency>
    142             <groupId>org.springframework</groupId>
    143             <artifactId>spring-instrument</artifactId>
    144             <version>${spring-version}</version>
    145         </dependency>
    146         <!-- 看名字就是提供对orm框架( JPA, JDO, and Hibernate)的支持 -->
    147         <!-- 如果用Mybatis,那就不要这个组件了 -->
    148         <dependency>
    149             <groupId>org.springframework</groupId>
    150             <artifactId>spring-orm</artifactId>
    151             <version>${spring-version}</version>
    152         </dependency>
    153         <!-- 看名字就是xml与object的mapping了 。就是把xml和pojo这件来回转换。 -->
    154         <dependency>
    155             <groupId>org.springframework</groupId>
    156             <artifactId>spring-oxm</artifactId>
    157             <version>${spring-version}</version>
    158         </dependency>
    159         <!-- 看名字就是提供对jms的支持了 -->
    160         <dependency>
    161             <groupId>org.springframework</groupId>
    162             <artifactId>spring-jms</artifactId>
    163             <version>${spring-version}</version>
    164         </dependency>
    165         <!-- 提供了基于portlet的mvc实现(By the way,我目前接触后台的mvc都是基于servlet或者filter实现的,所有大部分时候是不要这个东西的) -->
    166         <dependency>
    167             <groupId>org.springframework</groupId>
    168             <artifactId>spring-webmvc-portlet</artifactId>
    169             <version>${spring-version}</version>
    170         </dependency>
    171         <!-- spring 不常用组件结束 -->
    172         <dependency>
    173             <groupId>junit</groupId>
    174             <artifactId>junit</artifactId>
    175             <version>${junit-version}</version>
    176             <scope>test</scope>
    177         </dependency>
    178         <dependency>
    179             <groupId>log4j</groupId>
    180             <artifactId>log4j</artifactId>
    181             <version>1.2.14</version>
    182         </dependency>
    183 
    184         <!-- 没用过json,好意思说是程序员! -->
    185         <dependency>
    186             <groupId>net.sf.json-lib</groupId>
    187             <artifactId>json-lib</artifactId>
    188             <version>2.4</version>
    189             <classifier>jdk15</classifier>
    190         </dependency>
    191 
    192 
    193 
    194         <!-- 在spring-text组件中测试测试返回的json是什么,要下面两个包 -->
    195         <dependency>
    196             <groupId>net.minidev</groupId>
    197             <artifactId>json-smart</artifactId>
    198             <version>1.2</version>
    199             <scope>test</scope>
    200         </dependency>
    201         <dependency>
    202             <groupId>com.jayway.jsonpath</groupId>
    203             <artifactId>json-path</artifactId>
    204             <version>0.9.1</version>
    205             <scope>test</scope>
    206         </dependency>
    207 
    208         <dependency>
    209             <groupId>mysql</groupId>
    210             <artifactId>mysql-connector-java</artifactId>
    211             <version>5.1.35</version>
    212         </dependency>
    213 
    214         <!-- mybatis -->
    215         <dependency>
    216             <groupId>org.mybatis</groupId>
    217             <artifactId>mybatis</artifactId>
    218             <version>3.3.0</version>
    219         </dependency>
    220         <dependency>
    221             <groupId>org.mybatis</groupId>
    222             <artifactId>mybatis-spring</artifactId>
    223             <version>1.2.3</version>
    224         </dependency>
    225 
    226 
    227         <!-- 这两个包是jstl表达式需要的包,jstl就是常用的 c:foreach;c:if什么的 -->
    228         <dependency>
    229             <groupId>taglibs</groupId>
    230             <artifactId>standard</artifactId>
    231             <version>1.1.2</version>
    232         </dependency>
    233         <dependency>
    234             <groupId>jstl</groupId>
    235             <artifactId>jstl</artifactId>
    236             <version>1.2</version>
    237         </dependency>
    238         <!-- 使用hibernate进行数据校验需要下面这个组件,其实这个组件还依赖jboss-logging,validation-api等, -->
    239         <!-- 不过maven会帮我们自动处理这个依赖的。 -->
    240         <dependency>
    241             <groupId>org.hibernate</groupId>
    242             <artifactId>hibernate-validator</artifactId>
    243             <version>5.1.3.Final</version>
    244         </dependency>
    245 
    246         <!-- 不是说spring整合ehcache比较好吗?为什么不用呢 -->
    247         <dependency>
    248             <groupId>net.sf.ehcache</groupId>
    249             <artifactId>ehcache-core</artifactId>
    250             <version>2.6.0</version>
    251         </dependency>
    252 
    253 
    254         <!-- 下面是常用的apache的 commons-xxx -->
    255         <dependency>
    256             <groupId>commons-fileupload</groupId>
    257             <artifactId>commons-fileupload</artifactId>
    258             <version>1.3</version>
    259         </dependency>
    260         <dependency>
    261             <groupId>commons-lang</groupId>
    262             <artifactId>commons-lang</artifactId>
    263             <version>2.6</version>
    264         </dependency>
    265         <dependency>
    266             <groupId>commons-io</groupId>
    267             <artifactId>commons-io</artifactId>
    268             <version>2.4</version>
    269         </dependency>
    270         <dependency>
    271             <groupId>commons-collections</groupId>
    272             <artifactId>commons-collections</artifactId>
    273             <version>3.2.1</version>
    274         </dependency>
    275         <dependency>
    276             <groupId>commons-beanutils</groupId>
    277             <artifactId>commons-beanutils</artifactId>
    278             <version>1.9.2</version>
    279         </dependency>
    280 
    281     </dependencies>
    282 
    283     <build>
    284         <finalName>weixin</finalName>
    285         <plugins>
    286             <!-- 这个plugin 保证maven编译用的是java 1.7 -->
    287             <plugin>
    288                 <artifactId>maven-compiler-plugin</artifactId>
    289                 <version>3.0</version>
    290                 <configuration>
    291                     <source>1.7</source>
    292                     <target>1.7</target>
    293                 </configuration>
    294             </plugin>
    295             <!-- 这个plugin配置保证在测试时以Abstract开头的类不进行测试 -->
    296             <plugin>
    297                 <groupId>org.apache.maven.plugins</groupId>
    298                 <artifactId>maven-surefire-plugin</artifactId>
    299                 <version>2.5</version>
    300                 <configuration>
    301                     <excludes>
    302                         <exclude>**/**/Abstract*.java</exclude>
    303                     </excludes>
    304                 </configuration>
    305             </plugin>
    306 
    307             <!-- 下面这个plugin是jetty容器插件 -->
    308             <plugin>
    309                 <groupId>org.mortbay.jetty</groupId>
    310                 <artifactId>maven-jetty-plugin</artifactId>
    311                 <version>6.1.10</version>
    312                 <configuration>
    313                     <scanIntervalSeconds>10</scanIntervalSeconds>
    314                     <stopKey>foo</stopKey>
    315                     <stopPort>9999</stopPort>
    316                 </configuration>
    317                 <executions>
    318                     <execution>
    319                         <id>start-jetty</id>
    320                         <phase>pre-integration-test</phase>
    321                         <goals>
    322                             <goal>run</goal>
    323                         </goals>
    324                         <configuration>
    325                             <scanIntervalSeconds>0</scanIntervalSeconds>
    326                             <daemon>true</daemon>
    327                         </configuration>
    328                     </execution>
    329                     <execution>
    330                         <id>stop-jetty</id>
    331                         <phase>post-integration-test</phase>
    332                         <goals>
    333                             <goal>stop</goal>
    334                         </goals>
    335                     </execution>
    336                 </executions>
    337             </plugin>
    338             <!-- 这是cargo插件,不知道cargo是什么!好吧,cargo可以实现自动化部署 -->
    339             <!-- 下面的配置就是把war包自动发送到192.168.128.137:8080的tomcat中 -->
    340             <plugin>
    341                 <groupId>org.codehaus.cargo</groupId>
    342                 <artifactId>cargo-maven2-plugin</artifactId>
    343                 <version>1.4.9</version>
    344                 <configuration>
    345                     <container>
    346                         <containerId>tomcat7x</containerId>
    347                         <type>remote</type>
    348                     </container>
    349                     <configuration>
    350                         <type>runtime</type>
    351                         <properties>
    352                             <cargo.remote.uri>http://192.168.128.137:8080/manager/text</cargo.remote.uri>
    353                             <cargo.remote.username>admin</cargo.remote.username>
    354                             <cargo.remote.password>admin</cargo.remote.password>
    355                         </properties>
    356                     </configuration>
    357                 </configuration>
    358             </plugin>
    359         </plugins>
    360     </build>
    361 
    362 </project>
  • 相关阅读:
    注册事件为何无效,没有触发? AUTOPOSTBACK已经设置为TRUE
    不使用web服务实现文本框自动完成扩展
    实现一个搜索功能思路
    QT练习3:QT数字和滚动条关联
    Qt 显示图片 放大 缩小 移动
    QT 的信号与槽机制介绍
    一个有很多QT免费应用例程的网站
    yafeilinux.com的开源项目非常好的东西
    vector的用法
    C语言实现获取LINUX当前时间
  • 原文地址:https://www.cnblogs.com/formyjava/p/4698490.html
Copyright © 2011-2022 走看看