`
yaasshole
  • 浏览: 665406 次
文章分类
社区版块
存档分类
最新评论

Maven3安装以及基本使用

 
阅读更多

我自己的英文笔记的一部分,没多少英文,所以就懒得翻译了。

Download and install maven3.0.2

wget -c http://apache.etoak.com//maven/binaries/apache-maven-3.0.2-bin.tar.gz tar -zxvf apache-maven-3.0.2-bin.tar.gz

add the following into ~/.bashrc or ~/.bash_profile file export MAVEN_HOME=/home/chenshu/work/apache-maven-3.0.2 export PATH=$PATH:$MAVEN_HOME/bin

crate a Java application project

mvn archetype:generate -DgroupId=com.example -DartifactId=FileToDB -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

execute a plugin directly

you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal

Show dependency tree

Run the following command under your maven2 project,it will show all dependency files of your project jar file.
mvn dependency:tree

For example:
~/work/svnclient/Exactor/AccountAPIs/BulkUpload/portage $ mvn dependency:tree
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ————————————————————————
[INFO] Building portage
[INFO] task-segment: [dependency:tree]
[INFO] ————————————————————————
[INFO] [dependency:tree {execution: default-cli}]
[INFO] com.exactor.bulkupload:portage:jar:1.0-SNAPSHOT
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.mybatis:mybatis:jar:3.0.1:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.6:compile
[INFO] +- commons-io:commons-io:jar:1.4:compile
[INFO] /- junit:junit:jar:3.8.1:test
[INFO] ————————————————————————
[INFO] BUILD SUCCESSFUL
[INFO] ————————————————————————
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Aug 31 20:34:45 CST 2010
[INFO] Final Memory: 16M/301M

Copy dependency

For example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>

Then run this command:
mvn dependency:copy-dependencies

all dependencies will be copied to task/dependency folder.

Executable jar


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.exactor.bulkupload.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
mvn jaxws:wsimport

Respository path

~/.m2/respository For example,JSF2 jar file locates in my computer: /home/chenshu/.m2/repository/com/sun/faces/jsf-api/2.0.3-b03/jsf-api-2.0.3-b03.jar

manage glassfish server

<plugin>

<groupId>org.glassfish.maven.plugin</groupId> <artifactId>maven-glassfish-plugin</artifactId> <version>2.1</version> <configuration> <glassfishDirectory>/usr/local/glassfish-3.0.1</glassfishDirectory> <user>admin</user> <passwordFile>/home/chenshu/glassfishi_password</passwordFile> <debug>true</debug> <terse>true</terse> <echo>true</echo> <domainDirectory>/usr/local/glassfish-3.0.1/glassfish/domains</domainDirectory> <domain> <name>domain1</name> </domain> <components> <component> <name>${project.artifactId}</name> <artifact>target/${project.build.finalName}.war</artifact> </component> </components> </configuration> </plugin>

execute the following command: touch /home/chenshu/glassfish_password mvn org.glassfish.maven.plugin:maven-glassfish-plugin:start-domain mvn org.glassfish.maven.plugin:maven-glassfish-plugin:redeploy mvn -e org.glassfish.maven.plugin:maven-glassfish-plugin:start-domain mvn -e org.glassfish.maven.plugin:maven-glassfish-plugin:deploy note,don't execute the above commands in eshell of Emacs,shell should be used.

generate SOAP client with jaxws-maven-plugin

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<wsdlUrls>
<wsdlUrl>http://localhost:8080/entity-exemption/request/soap?wsdl</wsdlUrl>
</wsdlUrls>
<!—

<sourceDestDir>./src/main/java</sourceDestDir>—>

<sourceDestDir>${project.build.sourceDirectory}</sourceDestDir>
</configuration>
</plugin>

execute this command : mvn jaxws:wsimport

create a archetype from existing project and use it to create a new project

enter your existing project top-level folder,for example,I have a project named website:
cd website
mvn archetype:create-from-project
mvn install

The archetype will be named after your existing project's name.

Now you can crate a new project using this archetype in another folder,for example:
cd /home/chenshu/work
mvn archetype:generate -DarchetypeCatalog=local
If you installed several archetypes before,you need to choose one ,then you have a chance to set the groupId,artifactId,version and package for this new project.Very good!


* add faces-config.xml or other xml files into META-INF folder for JAR project
I just noticed that it seems to be very easy: Using Apache Maven you just need to create a META-INF folder in your src/main/resources. Every file placed in this directory will be copied into the META-INF folder of the jar. To create an out of the box usable JSF-component JAR archive you need to place the tld and a minimal faces-config.xml into /META-INF.

分享到:
评论

相关推荐

    Maven3实战视频教程(14集)

    Maven3_06_复习maven的基本内容 Maven3_07_nexus的介绍和安装 Maven3_08_nexus的配置 Maven3_09_发布项目到nexus中 Maven3_10_生命周期和插件简介 Maven3_11_插件基础 Maven3_12_插件的应用 Maven3_13_测试 Maven3_...

    编程开发+Maven技术+Maven安装与配置+技术课程

    课程内容从Maven的基本概念讲起,详细介绍了Maven的安装过程、环境配置、以及如何通过Maven进行项目构建和管理。我们不仅涵盖了Windows、Linux和macOS等主流操作系统下的Maven安装步骤,还提供了丰富的实践指导,...

    maven window下安装包

    第10章:使用Maven进行测试/10.4 跳过测试/10.3.4 配置插件跳过测试以及跳过测试代码编译 第10章:使用Maven进行测试/10.5 动态指定要测试的类/10.5.1 指定若干个类 第10章:使用Maven进行测试/10.5 动态指定要测试...

    在IDEA的maven项目中连接并使用MySQL8.0的方法教程

    首先看一下我的基本的开发环境: ...3.第一个选中maven安装的文件夹,第二个选中maven安装文件夹中的conf/settings.xml,第三个如果settings.xml中配置了localRepository,则会自动填入,若没有则会显示默认的本地

    Maven介绍安装和配置详解

    1. **项目对象模型(POM)**:Maven使用一个XML文件(pom.xml)来描述项目的基本信息,如项目名称、版本、依赖项等。通过这个文件,Maven可以自动化地完成项目的构建、依赖管理、报告生成等工作。 2. **依赖管理**:...

    maven可以帮助者我们完成一站式部署

    maven的安装与配置 1.安装 从网络将maven下载. 直接解压就可以. 2.配置 基本配置 1.需要jdk1.6版本 JAVA_HOME 2.在环境变量在设置 MAVEN_HOME=D:\apache-maven-3.1.0 3...

    maven3+mybatis3+dwr3实现的的异步刷新产品信息系统

    Maven3+mybatis3+dwr3+mysql5.5,请用Chrome浏览器,兼容性还未调试。 自己写的一个小系统,包含一个模块:产品模块。 基本这个模块包括的内容就比较多了,CRUD,无刷新查询,图片上传等, 其实也是整个系统最复杂的...

    Maven分模块开发构建SSM基本框架

    Maven分模块开发SSM基本框架,有基本的示例文件,以及大量的注释,只需要打开注释就可以快速开发。略微的修改就可以变更许多操作 #### 软件架构 软件架构说明 #### 安装教程 IDEA导入即可 #### 使用说明 1. ...

    maven3+spring3+mybatis3+dwr3实现的的异步刷新产品信息系统

    Maven3+spring3+mybatis3+dwr3+mysql5.5,请用Chrome浏览器,兼容性还未调试。 自己写的一个小系统,包含一个模块:产品模块。 基本这个模块包括的内容就比较多了,CRUD,无刷新查询,图片上传等, 其实也是整个...

    gencode-maven-plugin:基本功能能够完成,并测试通过

    代码生成器maven插件目录gencode-maven-plugin安装步骤1.下载并编译mini-inject地址: : 执行命令 git clone ...

    java8源码-Spring4Hibernate5Maven:基于spring4.2.4+Hibernate5.0.7final搭建的Mave

    1、Maven安装以及在eclipse中的配置 2、Eclipse中使用Maven创建基本的web项目 3、Maven的Web工程集成Spring4 1、使用Eclipse搭建Maven的Web工程 请参考:Eclipse中使用Maven创建基本的web项目 2、Maven的Web工程集成...

    autoinstallhadoop:自动安装JDK,Maven,Ant,Maven,Hadoop脚本

    autoinstallhadoop ...全是Java有关的框架,主要目的在于安装Hadoop,其他的都是附带的基本配置 本脚本能够快速在Linux上安装JAVA环境,并部署hadoop,其中关于hadoop,hbase和Zookeeper的配置 分别在压缩包内的

    mybatis基本使用

    以下是一个基本的 MyBatis 测试使用的描述: 1. 环境准备 首先,确保你已经安装了 Java 和 Maven,并且有一个可用的数据库环境(如 MySQL)。然后,在 Maven 项目中添加 MyBatis 的依赖。 2. 配置 MyBatis 在项目的 ...

    jTester使用指南(带书签).pdf

    maven用户安装 ant用户安装 安装TestNG插件 编写一个简单的测试用例 maven方式运行 第 2 章 TestNG语法简介 TestNg注解介绍 TestNg 参数化测试 异常测试 TestNg分组测试和suite文件编写 第 3 章 jTester断言...

    PyPomVisualiser:独立平台的Maven Pom结构可视化工具,用Python编写

    基本入门要求: Python 3.4 TKinter(在APT支持Linux发行版上,可以使用'sudo apt-get install python3-tk'来获得) 使用以下命令运行:python pypomv.py #Package安装说明cd / PyPomVisualiser使用以下命令安装:...

    JavaEE求职简历-姓名-JAVA开发工程师.doc

    8.熟练使用Maven来进行多模块项目的构建以及管理项目中依赖包,以及使用Maven最终完成项目的热部署; 9.熟悉junit技术,通过SpringTest、Dbunit、EasyMock对项目进行单元测试和集成测试; 10.了解基本Linux操作系统...

    grid-search:Grid Search estimator 通常用于训练参数

    要使用此 Java 库,您需要 Java 8 和 Maven 3。 安装 使用 Maven,您只需将以下内容添加到pom.xml的dependencies部分: &lt; groupId&gt;eu.crydee &lt; artifactId&gt;grid-search &lt; version&gt;2.1.1 如果你不使用 maven...

    使用Spring Boot的小型诊所信息系统,毕业设计Java版

    安装maven 启用Idea 导入项目 在项目的resource目录下有myclinic.sql文件,将其导入到MySQL中 已有账号信息 系统管理员 用户名:user1 密码:123 病人管理员 用户名:user3 密码:123 血液科医生 用户名:user5 密码...

    shell脚本自动化创建虚拟机的基本配置之tomcat–mysql–jdk–maven

    ps:此处安装的jdk,maven,tomcat均在/opt目录下,如需其他目录或者其他版本,可根据需要改动shell脚本即可。 ps:所有代码全部手敲,已亲测能够使用,全部分享出来。 一:虚拟机初始化 创建shell脚本,把命令放进....

    Java基于SpringBoot+MyBatis新闻推荐系统.zip

    3、简化Maven配置; 4、自动配置Spring; 5、提供生产就绪功能,如指标,健康检查和外部配置; 6、绝对没有代码生成和XML的配置要求; 安装步骤: 最基本的是,Spring Boot是一个可以被任何项目的构建系统使用的...

Global site tag (gtag.js) - Google Analytics