(TT一)MAVEN管理项目

简介

使用maven管理工程。
1、依赖管理
2、项目构建

maven使用实例

淘淘商城(ssm)

**1. 创建taotao-parent,其为最大的父工程,打包方式为pom。
在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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>
    <groupId>com.taotaogroupId>
    <artifactId>taotao-parentartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <packaging>pompackaging>
    
    <properties>
        <junit.version>4.12junit.version>
        <spring.version>4.1.3.RELEASEspring.version>
        <mybatis.version>3.2.8mybatis.version>
        <mybatis.spring.version>1.2.2mybatis.spring.version>
        <mybatis.paginator.version>1.2.15mybatis.paginator.version>
        <mysql.version>5.1.32mysql.version>
        <slf4j.version>1.6.4slf4j.version>
        <jackson.version>2.4.2jackson.version>
    properties>
    
    <dependencyManagement>
        <dependencies>
            
            <dependency>
                <groupId>joda-timegroupId>
                <artifactId>joda-timeartifactId>
                <version>${joda-time.version}version>
            dependency>
        dependencies>
    dependencyManagement>
    <build>
        <finalName>${project.artifactId}finalName>
        <plugins>
            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-resources-pluginartifactId>
                <version>2.7version>
                <configuration>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
        plugins>
        <pluginManagement>
            <plugins>
                
                <plugin>
                    <groupId>org.apache.tomcat.mavengroupId>
                    <artifactId>tomcat7-maven-pluginartifactId>
                    <version>2.2version>
                plugin>
            plugins>
        pluginManagement>
    build>
project>

2. 创建taotao-common,保存是项目中用到的通用的工具类以及通用的pojo,打包方式jar包。

<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">
    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>com.taotaogroupId>
        <artifactId>taotao-parentartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <groupId>com.taotaogroupId>
    <artifactId>taotao-commonartifactId>
    <version>0.0.1-SNAPSHOTversion>
    
    <dependencies>
        
        <dependency>
            <groupId>joda-timegroupId>
            <artifactId>joda-timeartifactId>
        dependency>
    dependencies>
project>

3. 创建taotao-common,为聚合工程。打包方式pom

<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">
    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>com.taotaogroupId>
        <artifactId>taotao-parentartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <groupId>com.taotaogroupId>
    <artifactId>taotao-managerartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <packaging>pompackaging>
    
    <dependencies>
        <dependency>
            <groupId>com.taotaogroupId>
            <artifactId>taotao-commonartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
    dependencies>
project>

4. 添加模块taotao-manager-pojo,taotao-manager-dao,taotao-manager-Service,taotao-manager-web。
其中因为taotao-manager-web需要发布,打包方式为war,其它为jar。

常用命令与注意项

项目修改后可能会出现错误:选择Maven->update Project
maven项目使用tomcat插件运行:clean tomcat7:run

你可能感兴趣的:(TT)