网上摘抄、 暂且放这
=================================
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是一个基于项目对象模型(Project Object Model,POM)的软件项目管理和构建自动化工具。它可以帮助开发者管理项目的构建、...
maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置maven配置...
通过以上步骤,你可以成功地安装和配置Maven 3,并开始使用它进行Java项目的构建和管理。Maven的强大之处在于它的插件系统和中央仓库,可以自动下载和管理项目依赖,大大简化了开发和维护过程。随着对Maven的深入...
Maven的安装、配置及使用入门 ,强大的项目管理工具。
"STS及Maven的安装与配置" STS(Spring Tool Suite)是一款功能强大的集成开发环境,广泛应用于Java和SpringBoot开发中。而Maven是一款流行的项目管理工具,能够帮助开发者更好地管理项目依赖关系和编译过程。以下...
Maven 安装配置指南 本资源为 Maven 安装配置的详细指南,旨在帮助用户快速搭建 Maven 开发环境,并在 MyEclipse 中进行完美运行。以下是 Maven 安装配置的详细步骤: Step 1:下载 Maven 首先,需要下载 Maven ...
### Maven安装与配置详解 #### 一、Maven简介 Maven是一款由Apache软件基金会支持的项目管理和理解工具。它可以帮助开发者自动构建Java项目,并管理项目的依赖关系。Maven使用XML格式来描述项目的构建规则,这使得...
下面是 Maven 的安装和配置指南,适合初学者快速了解 Maven 的基本概念和使用方法。 一、Maven 的下载与安装 Maven 的下载和安装非常简单。首先,打开 Maven 官网地址:http://maven.apache.org/download.cgi,...
maven linux 安装时配置文件 settings.xml 配置阿里云镜像 使用时请修改本地仓库路径
通过上述步骤,您可以顺利地在本地环境中安装和配置 Maven 3.6.3,并将其集成到 IntelliJ IDEA 2022.2.3 中。这为自动化构建和管理 Java 项目的依赖提供了强大的支持。Maven 通过统一的生命周期模型、插件机制以及对...
将上述配置保存后,确保替换原有的Maven配置文件,以保证新配置生效。 #### Eclipse中Maven的配置 **2.1 打开Eclipse的首选项设置** - 在Eclipse中,选择`Window > Preferences`打开首选项设置窗口。 **2.2 找到...
maven下载安装与配置 maven下载安装与配置 maven下载安装与配置 maven下载安装与配置 maven下载安装与配置
** Maven3 安装教程详解 ** Maven 是一个强大的项目管理和构建工具,广泛应用于Java开发领域。它通过使用一种标准化的项目对象模型(Project Object Model, POM),自动管理项目的构建、报告和依赖关系。在本文档中...
maven下载安装与配置 maven下载安装与配置 maven下载安装与配置 maven下载安装与配置 maven下载安装与配置
### Maven安装与配置详解 ...综上所述,Maven的安装与配置涵盖了从基础环境搭建到高级插件的使用等多个方面。正确的安装和配置不仅可以提升开发效率,还能有效管理项目依赖,保证项目的顺利进行。
eclipse 里 Maven 的安装与配置 Maven 是一个软件项目管理和综合工具,通过特有的 POM(project object model)概念来管理项目,功能十分强大。下面将详细介绍 Maven 的安装和配置过程。 一、安装 Maven Maven 的...
ESElasticsearch maven下载安装与配置 maven下载安装与配置 maven下载安装与配置 maven下载安装与配置 maven下载安装与配置