网上摘抄、 暂且放这
=================================
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.
分享到:
相关推荐
Maven的安装、配置及使用入门
maven的安装与配置; maven的安装与配置 ;maven的安装与配置
Maven的安装、配置及使用入门 ,强大的项目管理工具。
maven3的安装配置和使用说明
此文档是maven安装配置,免费下载,随便下,给个好评哦
maven安装与配置
第3章 Maven使用入门16.3.1 编写POM17.3.2 编写主代码18.3.3 编写测试代码19.3.4 打包和运行20.3.5 使用Archetype生成项目骨架21.3.6 m2eclipse简单使用22.3.7 NetBeans Maven插件简单使用23.3.8 小结
STS及Maven的安装与配置,Spring Tool Suite 使用Spring Boot开发的第一步
详细的maven教程。适合初学者对于maven的安装配置以及常用命令简介
Maven3使用配置步骤 1. 下载Maven 2. 安装Maven 3. 设置仓库位置 4. 创建maven项目 5. 编译项目代码 6. 导入eclipse工具 7. 包的更新与下载
Maven的安装与环境变量的配置
Apache Maven是一个很流行的软件项目管理和理解工具,它能够被用来构建和管理任何基于java的项目,主要有以下...2、maven配置文件详解 2.1、localRepository配置 2.2、servers配置 2.3、mirrors配置 2.4、profiles配置
maven安装以及eclipse配置maven
maven linux 安装时配置文件 settings.xml 配置阿里云镜像 使用时请修改本地仓库路径
maven的安装配置手册 ,权威指南 。
Maven安装配置外加Myeclipse上完美运行图解_______自己总结,免费共享
Maven配置文件Maven配置文件
Maven的配置及使用,Maven的配置及使用Maven的配置及使用Maven的配置及使用Maven的配置及使用Maven的配置及使用Maven的配置及使用
maven3安装配置参考手册 详细讲述了maven的安装和配置过程,并附有详细且清晰的截图。