码迷,mamicode.com
首页 > 其他好文 > 详细

Maven学习笔记(一)

时间:2017-09-17 18:54:05      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:asp   构建   命令   spec   对象模型   director   des   使用步骤   开发   

Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。

技术分享

 

 3:使用步骤                                                                                                    
                            
    3.1 下载自己需要的maven工具包  3.3.9  解压                                                                                    
                                                      
    3.2 配置开发工具中(eclipse)的maven 环境 

                                                                                                                            
    3.3 改变本地仓库地址的位置                                                                                                
                                            技术分享

 

                                                                                                                              
    3.4 新建maven 项目 工程类型介绍 

技术分享

 

 技术分享

                                                                                                                                                       
    3.5 在pom 文件中添加需要依赖的jar包                                                                                                
                                                                                                                                                                   
    3.6 maven 工程目录的介绍   

 

3.7  maven 常见标签                                                                                
                                                                                
        <!-- 排除传递的依赖 -->                                                                        
                    <exclusions>                                                            
                        <exclusion>                                                        
                            <artifactId>javassist</artifactId>                                                    
                            <groupId>javassist</groupId>                                                    
                        </exclusion>                                                        
                    </exclusions>                                                            
                                                                                
                                                                                
3.8 使用插件                                                                                
                                                                                
    <!-- 插件 -->                                                                            
            <plugins>                                                                    
                <plugin>                                                                
                    <groupId>org.apache.maven.plugins</groupId>                                                            
                    <artifactId>maven-resources-plugin</artifactId>                                                            
                    <version>2.5</version>                                                            
                </plugin>                                                                
                <plugin>                                                                
                    <groupId>org.apache.maven.plugins</groupId>                                                            
                    <artifactId>maven-compiler-plugin</artifactId>                                                            
                    <version>2.3.2</version>                                                            
                    <configuration>                                                            
                        <source>1.7</source>                                                        
                        <target>1.7</target>                                                        
                    </configuration>                                                            
                </plugin>                                                                
                <!-- 引入tomcat插件 -->                                                                
                <plugin>                                                                
                    <groupId>org.apache.tomcat.maven</groupId>                                                            
                    <artifactId>tomcat7-maven-plugin</artifactId>                                                            
                    <version>2.2</version>                                                            
                    <configuration>                                                            
                        <path>/crm</path>                                                        
                        <port>8888</port>                                                        
                    </configuration>                                                            
                </plugin>                                                                
            </plugins>                                                                    
                                                                                
3.9 常见命令                                                                                
                                                                                
        编译项目                                                                        
        mvn compile                                                                        
                                                                                
        打包                                                                        
        mvn package                                                                        
                                                                                
        清理(删除target目录下编译内容)                                                                        
        mvn clean                                                                        
                                                                                
        install是把打出的包装载到本地仓库                                                                        
        mvn install       

Maven搭建SSH环境依赖的jar包配置
  <properties>                    
        <spring.version>4.2.4.RELEASE</spring.version>            
        <hibernate.version>3.3.2.GA</hibernate.version>            
        <struts2.version>2.1.8</struts2.version>            
        <slf4j.version>1.6.6</slf4j.version>            
        <log4j.version>1.2.12</log4j.version>            
    </properties>                
                    
    <dependencies>
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-test</artifactId>        
            <version>${spring.version}</version>        
        </dependency>                
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-context</artifactId>        
            <version>${spring.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-context-support</artifactId>        
            <version>${spring.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-web</artifactId>        
            <version>${spring.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-orm</artifactId>        
            <version>${spring.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-beans</artifactId>        
            <version>${spring.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.springframework</groupId>        
            <artifactId>spring-core</artifactId>        
            <version>${spring.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.aspectj</groupId>        
            <artifactId>aspectjweaver</artifactId>        
            <version>1.7.4</version>        
        </dependency>            
                    
        <!-- struts2 begin -->            
        <dependency>            
            <groupId>org.apache.struts</groupId>        
            <artifactId>struts2-core</artifactId>        
            <version>${struts2.version}</version>        
            <!-- 排除传递的依赖 -->        
            <exclusions>        
                <exclusion>    
                    <artifactId>javassist</artifactId>
                    <groupId>javassist</groupId>
                </exclusion>    
            </exclusions>        
        </dependency>            
        <dependency>            
            <groupId>org.apache.struts</groupId>        
            <artifactId>struts2-spring-plugin</artifactId>        
            <version>${struts2.version}</version>        
        </dependency>            
        <dependency>            
            <groupId>org.apache.struts</groupId>        
            <artifactId>struts2-convention-plugin</artifactId>        
            <version>${struts2.version}</version>        
        </dependency>            
        <!-- struts2 end -->            
                    
        <!-- hibernate begin -->            
        <dependency>            
            <groupId>org.hibernate</groupId>        
            <artifactId>hibernate-core</artifactId>        
            <version>${hibernate.version}</version>        
        </dependency>            
        <!-- hibernate end -->            
                    
        <!-- log start -->            
        <dependency>            
            <groupId>log4j</groupId>        
            <artifactId>log4j</artifactId>        
            <version>${log4j.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.slf4j</groupId>        
            <artifactId>slf4j-api</artifactId>        
            <version>${slf4j.version}</version>        
        </dependency>            
                    
        <dependency>            
            <groupId>org.slf4j</groupId>        
            <artifactId>slf4j-log4j12</artifactId>        
            <version>${slf4j.version}</version>        
        </dependency>            
        <!-- log end -->            
        <dependency>            
            <groupId>junit</groupId>        
            <artifactId>junit</artifactId>        
            <version>4.10</version>        
            <scope>test</scope>        
        </dependency>            
                    
        <!-- 加入servlet和jsp的依赖 -->            
        <dependency>            
            <groupId>jstl</groupId>        
            <artifactId>jstl</artifactId>        
            <version>1.2</version>        
            <scope>provided</scope>        
        </dependency>            
        <dependency>            
            <groupId>javax.servlet</groupId>        
            <artifactId>servlet-api</artifactId>        
            <version>2.5</version>        
            <scope>provided</scope>        
        </dependency>            
        <dependency>            
            <groupId>javax.servlet</groupId>        
            <artifactId>jsp-api</artifactId>        
            <version>2.0</version>        
            <scope>provided</scope>        
        </dependency>            
                    
        <!-- 引入c3p0jar包 -->            
        <dependency>            
            <groupId>c3p0</groupId>        
            <artifactId>c3p0</artifactId>        
            <version>0.9.1.2</version>        
        </dependency>            
        <!-- 引入MySQL数据库驱动依赖 -->            
        <dependency>            
            <groupId>mysql</groupId>        
            <artifactId>mysql-connector-java</artifactId>        
            <version>5.1.32</version>        
        </dependency>            
        <dependency>            
            <groupId>commons-dbcp</groupId>        
            <artifactId>commons-dbcp</artifactId>        
            <version>1.4</version>        
        </dependency>            
    </dependencies>                
                    
    <build>                
        <!-- 插件 -->            
        <plugins>            
            <plugin>        
                <groupId>org.apache.maven.plugins</groupId>    
                <artifactId>maven-resources-plugin</artifactId>    
                <version>2.5</version>    
            </plugin>        
            <plugin>        
                <groupId>org.apache.maven.plugins</groupId>    
                <artifactId>maven-compiler-plugin</artifactId>    
                <version>2.3.2</version>    
                <configuration>    
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>    
            </plugin>        
            <!-- 引入tomcat插件 -->        
            <plugin>        
                <groupId>org.apache.tomcat.maven</groupId>    
                <artifactId>tomcat7-maven-plugin</artifactId>    
                <version>2.2</version>    
                <configuration>    
                    <path>/testSSH</path>
                    <port>8888</port>
                </configuration>    
            </plugin>        
        </plugins>            
        <resources>            
            <resource>        
                <directory>src/main/java</directory>    
                <includes>    
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>    
                <filtering>false</filtering>    
            </resource>        
            <resource>        
                <directory>src/main/resources</directory>    
                <includes>    
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>    
                <filtering>false</filtering>    
            </resource>        
        </resources>            
    </build>                
</project>

 

 

 

运行Maven的web项目

 

 配置运行命令

技术分享

技术分享

 

Maven学习笔记(一)

标签:asp   构建   命令   spec   对象模型   director   des   使用步骤   开发   

原文地址:http://www.cnblogs.com/zzx6/p/7536406.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!