`

APACHE的MAVEN管理jar包

 
阅读更多

1、MAVEN的安装和配置
项目地址:
http://maven.apache.org/download.html

下载到的文件:
apache-maven-2.0.9-bin.zip

接压缩后拷贝到tool下面。配置path中加入:
D:\tool\apache-maven-2.0.9\bin

然后在命令行中输入:
mvn -version

返回:
Maven version: 2.0.9
Java version: 1.5.0_12
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
maven就安装好了

maven命令
mvn test:运行应用程序中的单元测试
mvn package:依据项目生成jar文件
mvn install,把包安装在本地的repository中,可以被其他工程作为依赖来使用
mvn site:生成项目相关信息的网站
mvn clean:清除目标目录中的生成结果
mvn eclipse:eclipse:生成Eclipse项目文件
mvn deploy,在整合或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享。

可以通过对目标及相位的组合使得一个命令完成多个功能,比如:
mvn clean dependency:copy-dependencies package
关于常用命令的详解,见参考资料。

2、MYECLIPSE6.5
项目地址:
http://www.myeclipseide.com/

SN:
Subscriber: xiaofei
Subscription Code: kLR8ZO-655111-53678656277609555

新建WEB项目的时候ADD MAVEN的支持

3、MAVEN和MYECLIPSE
目前是只用MAVEN来管理JAR包,pom.xml文件如下,删除其中build的配置:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sillycat</groupId>
<artifactId>easyview</artifactId>
<packaging>war</packaging>
<name />
<version>0.0.1-SNAPSHOT</version>
<description />
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>com.ibatis</groupId>
<artifactId>ibatis2-dao</artifactId>
<version>2.1.7.597</version>
</dependency>
</dependencies>
</project>

运行如下命令:
mvn clean dependency:copy-dependencies
会生成target/dependency目录,将jar包拷贝到dependency目录

还是使用ant来编译打包,其实这样比较土,不过自己用起来比较熟悉。先用

mvn clean dependency:copy-dependencies

然后用

ant war 打包,两个过程了。。。。

build.xml如下:
<!-- modified by sillycat.luohua 2008.06.27 -->
<project name="easyview" default="compile" basedir=".">
<!-- set global properties for this build -->
<!-- 项目名字 -->
<property name="project" value="easyview" />
<!-- 源代码路径 -->
<property name="src" location="src/java" />
<!-- 所有的配置文件 -->
<property name="config" location="src/conf" />
<!-- web项目的根 -->
<property name="web" location="WebRoot" />
<!-- web中用到的jar包 -->
<property name="web-lib" location="${web}/WEB-INF/lib" />
<!-- build出class的路径 -->
<property name="build" location="build" />
<!-- 生成war包和项目部署配置文件的路径 -->
<property name="dist" location="dist" />
<!-- maven管理的jar包 -->
<property name="maven-jar" location="target/dependency" />

<!-- 编译项目的classpath设置 -->
<path id="classpath.compile">
<fileset dir="${web-lib}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${build}" />
</path>

<target name="init">
<!-- 编译前先生成目录 -->
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<copy todir="${web-lib}">
<fileset dir="${maven-jar}" includes="*.jar">
</fileset>
</copy>
</target>

<target name="compile" depends="init" description="compile the source">
<mkdir dir="${build}/classes" />
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}/classes" debug="true" deprecation="true" optimize="false" failonerror="true" encoding="utf-8">
<classpath refid="classpath.compile" />
</javac>
</target>

<!-- 拷贝页面资源到build中 -->
<target name="copyWebFiles" depends="compile">
<mkdir dir="${build}/web" />
<copy todir="${build}/web">
<fileset dir="${web}" excludes="WEB-INF/classes/">
</fileset>
</copy>
<copy todir="${build}/web/WEB-INF/classes">
<fileset dir="${build}/classes">
</fileset>
<fileset dir="${config}">
<exclude name="**/easyview.properties" />
</fileset>
</copy>
</target>

<!-- 拷贝配置资源给本机测试用 -->
<target name="config4debug">
<copy file="${config}/easyview.properties" tofile="${dist}/easyview.properties" />
</target>

<!-- 拷贝配置资源给发布用 -->
<target name="config4release">
<copy file="${config}/easyview.properties" tofile="${dist}/easyview.properties" />
</target>

<!-- 生成war包 -->
<target name="buildWar">
<mkdir dir="${dist}" />
<war destfile="${dist}/${project}.war" webxml="${build}/web/WEB-INF/web.xml">
<fileset dir="${build}/web" />
</war>
</target>

<!-- 打包给本机测试 -->
<target name="war" depends="clean,copyWebFiles,config4debug,buildWar" description="generate the war package for personal debug">
</target>

<!-- 打包给发布使用 -->
<target name="release" depends="clean,copyWebFiles,config4release,buildWar" description="generate the war package for release">
</target>
<!-- 编译打包前先清空 -->
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>

 

分享到:
评论

相关推荐

    apache maven安装包和maven实用技巧

    apache maven安装包,maven实用技巧,java jar包,pom文件

    maven的jar包跟源码包

    maven的jar包跟源码包 apache-maven-3.5.2-bin&apache;-maven-3.5.2-src

    各种jar包,因为有些maven是下载不了一些jar包的,提供了一些下载jar包.zip

    fastjson-1.2.62.jar flex-messaging-core-4.0.0.jar jep-2.3.1.jar jsr250-api-1.0.jar Oracle_10g_10.2.0.4_JDBC_ojdbc14.jar org.apache.commons.httpclient.jar

    apache maven入门教程

    在JAVA界,可能大家比较熟悉ANT,它提供了强大的功能,让我们的开发工作变得如此有趣,APACHE又推出了新一代项目管理工具——MAVEN。它提供了比ANT更强大的管理功能,可以使用命令行工具来生成一个新的项目,管理已...

    apache commons 常用jar包 commons-validator commons-transaction commons-lang等

    jar包大小:342KB log4j-1.2.6.jar jar包大小:135KB commons-validator-1.3.1.jar jar包大小:93KB commons-transaction-1.2.jar jar包大小:141KB commons-scxml-0.6.jar jar包大小:254KB commons-primitives-1.0.jar ...

    Maven 和Maven下载的jar包库

    包含Maven程序apache-maven-3.3.9-bin.zip,解压到无中文目录即可使用;和Maven的本地jar包库方便使用,不用什么都去下载

    apache-maven-3.5.3

    apache-maven-3.5.3.jar包,apache-maven-3.5.3.jar包

    apache.poi所需要的jar包集合

    jar包个数:7个 apache的poi,操作Excel的包,亲测 jdk11 maven项目环境下包含本地jar使用有效,并给出了简单易用的封装。 传送门:我的博文:基于poi4.1.0的Excel表读写操作 日期:2020.12.15日

    apache-maven-3.6.3.rar

    用Maven来管理jar包,帮我们处理以上所有流程. 1.仓库 远程仓库/中央仓库: 本质上就是一个 国外的 网址 镜像仓库: 本质上就是一个 国内的 网址,网站上存了去中央仓库下载好的jar包,常用的是阿里云 本地仓库: 就是你...

    apache-maven-3.8.6

    apache-maven-3.8.6,里面的settings.xml文件已经配置阿里云镜像。

    apache-maven-3.2.5-bin

    比如我们搭建一个Struts2的开发框架时,光光有struts2-core-2.3.16.3.jar这个jar包是不行的,struts2-core-2.3.16.3.jar还依赖其它的jar包,依赖管理指的就是使用Maven来管理项目中使用到的jar包,Maven管理的方式...

    org.apache.poi JAR包 Java

    org.apache.poi JAR包,解决import org.apache.poi.hssf.usermodel.HSSFWorkbook; 支持office全系excel文件解析。 import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; ...

    apache-maven-3.3.3.zip

    maven

    apache-maven-3.2.5

    maven导入jar包

    apache.commons所有jar包

    apache.commons所有jar包,包括源码和api

    apache-maven-3.6.zip

    Maven 除了以程序构建能力为特色之外,还提供高级项目管理工具。由于 Maven 的缺省构建规则有较高的可重用性,所以常常用两三行 Maven 构建脚本就可以构建简单的项目。由于 Maven 的面向项目的方法,许多 Apache ...

    apache-maven-3.6.3.zip

    特有的pom文件管理jar包的配置,让你从繁琐的jar包中解脱出来,只要联网,根据配置的文件,maven会自动从互联网下载jar包。 而且maven特有的框架结构,让你轻松管理配置文件和项目源码,不会因为项目的错综复杂导致...

    apache-maven-3.6.0

    apache-maven-3.6.0安装包,解压即用!

    apache-maven-3.8.1

    项目管理:依赖管理-项目中需要使用的其他资源,常见的是jar包(管理项目中各种jar包)。在没有Maven前,我们需要去网络上下载需要的正确版本的jar包,并且手工处理jar包之间的依赖。 自动构建:帮助开发人员做项目...

    org.apache.HTTP需要的jar包.zip

    org.apache.HTTP需要的jar包,常用于Web开发,比如JSP+Servlet的学习,SSM\SSH等

Global site tag (gtag.js) - Google Analytics