maven 3 安装即配置使用

网上摘抄、 暂且放这

=================================

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是一个维护版本,主要是bug修复: ** Bug * [MNG-4840] - Prerequisites is not working on m3 * [MNG-4913] - [regression] User properties override equally named POM properties of transitive dependencies * [MNG-4915] - Versions in pom.xml are not checked for invalid characters * [MNG-4918] - MavenProject#clone() doubles active profiles * [MNG-4919] - Plugin execution contributed by lifecycle mapping gets lost when same goal is bound multiple times * [MNG-4923] - [regression] java.lang.ClassNotFoundException: org.apache.maven.artifact.ArtifactStatus * [MNG-4925] - Mismanagement of container lookup realm can cause type incompatibilities for plugins looking up components by string * [MNG-4933] - With a resource directory as . maven raise an java.lang.StringIndexOutOfBoundsException:217 * [MNG-4941] - PluginDescriptorBuilder doesn't populate expression/default-value fields for mojo parameters * [MNG-4952] - [regression] RELEASE field of repository metadata is not updated upon repeated deployments * [MNG-4955] - [regression] Outdated remote snapshots are preferred over locally installed snapshots * [MNG-4960] - [regression] Make-like reactor mode does not build selected project when resuming from one of its prerequisites * [MNG-4966] - Preserve double slashes in the scm connection url - identifies absolute repository paths for mercurial ** Improvement * [MNG-4912] - Use of raw type should be Comparable<ArtifactVersion> * [MNG-4916] - Poor ProjectBuilder.build performance for projects with unresolvable extension plugins * [MNG-4922] - ExecutionEvent give on the exception encountered (when having mojoFailed) * [MNG-4926] - ExecutionEvent give on the exception encountered (when having projectFailed , forkedProjectFailed) * [MNG-4944] - Include JRE vendor in version info * [MNG-4950] - Javadoc improvements to DefaultSettingsWriter/Reader * [MNG-4953] - Issue a warning when a system-scope dependency refers to the project basedir ** New Feature * [MNG-4936] - Allow to better monitor and adjust a Maven build during CI * [MNG-4937] - Allow the platform scripts to avoid loading mavenrc content ** Task * [MNG-4945] - Remove mergeId from public POM * [MNG-4957] - Emit validation warning when project version uses irregular SNAPSHOT version string * [MNG-4959] - Update default plugin versions
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值