Arch-05-13-maven Frequently Asked Questions

sponsored links

maven Frequently Asked Questions

http://www.cnblogs.com/BigTall/archive/2011/03/23/1993253.html

1 Introduction


Maven, pronounced [`meivin]," expert "means. It is a good project management tools, very early into the ranks of my essential tools, but this time in order to complete the migration project project1 and apply maven, so maven carried out some in-depth study. The purpose of this study notes to write a memo to himself, two others want to be able to shorten the time to learn how to use maven.

2. Maven Summary


First, I put the maven concept of sorting out quickly and let us quickly establish a more precise maven scenarios.

2.1 maven is not


Read first time limits, to avoid harmful reverie. Maven is not to say we can start from the following points to

  1. maven is not ant, not make.
    We had contact with the build tools, you need to write some detailed steps, such as: compile project1/src / *. java and similar statements. The statement is what we use ant and make something to be prepared. maven with a "convention over configuration" approach, a number of steps to develop common actions and has been cured in maven, so users no longer need to write those annoying statements. At the same time, maven built-in support of the development process, it is not only able to compile, the same can be packaged, released, and can finish all of these steps in one go.
  2. maven ivy is not
    Maven dependency management is one of the functions, although many people including me are only used before its dependency management capabilities, but to further use, we can see more content. More importantly, maven dependencies in the concept of adding a scope to further refine the dependency division.

2.2 maven is


maven is positioning itself as a project management tool. It is responsible for managing the project development process in almost everything:

  1. Version
    maven has its own version of the definitions and rules
  2. Construction
    maven supports many kinds of application types, for each of the supported application types are also defined a set of building rules and tools.
  3. Output of waste management
    maven can manage the project to build the product and add it to the user library. This feature can be used for the project team and other departments of the delivery behavior.
  4. Dependency
    maven dependencies of the characteristics of the detailed analysis and classification to avoid confusion during the development of dependence and mutual acts of pollution
  5. Documents and build results
    the maven site command the release of information to support a variety of documents, including the build process a variety of output, javadoc, product documentation.
  6. The relationship usually has a large project or several small projects module, it is easy to use maven to manage
  7. Transplant management
    maven can be developed for different scenarios, the output of different types of output.

2.3 maven life cycle


maven to build the project life cycle is divided into different (lifecycle), in my opinion, is very carefully divided, and we can refer here . A little rough, then it is this process (phase) include: compile, test, package, integration testing, validation, deployment. maven perform all the actions (goal) need to specify their own in the process of implementation of the location, then maven execution time, in accordance with the process of development in order to call these various treatment goal.

This is a basic scheduling mechanism maven. In general, the location will depend on later in the process before the process. Of course, maven also provides a configuration file, in accordance with user requirements, to skip some stages.

2.4 maven of "convention over configuration"


The so-called "convention over configuration" in maven is not entirely can not be amended, they are just some of the configuration of the default values only. However, users unless absolutely necessary, do not need to modify the content of those conventions. maven default file storage is structured as follows:

  • / Project directory
    • configuration file for the maven pom.xml
    • / Src source code directory
      • / Src / main project source directory
        • / Src / main / java project java source code directory
      • / Src / main / resource project Resource Directory
      • / Src / test unit test directory
        • / Src / test / java
    • / Target output directory, all the output objects are stored in this directory
      • / Target / classes compile class file after the


Each stage of the task knows how to do their jobs properly, such as compile task to know from the src / main / java compile all java files, and its output class file to the target / classes in the.

Of maven, the use of "convention over configuration" approach can reduce the workload of modifying the configuration, can also reduce learning costs, more importantly, the project introduced a unified standard.

2.5 maven version of specification


maven using the following several elements to uniquely locate a particular output object: groupId: artifactId: packaging: version. For example org.springframework: spring: 2.5. Each part of the explanation is as follows:

  • groupId
    Organizations, companies, groups, organizations, projects, or other groups. The convention is to identify the groups, it is to create the project organization name of reverse domain name (reverse domain name) at the beginning. There is a project from Sonatype beginning to com.sonatype groupId, the Apache Software projects have to org.apache beginning groupId.
  • artifactId
    GroupId, said in a separate project under a unique identifier. Such as our tomcat, commons, etc. Do not artifactId contains dots (.)
  • version
    Specific version of a project. The project has released a fixed version of the logo of the project to point to one specific version. The project now in development can use a special logo, this logo to the version with a "SNAPSHOT" tag.
    Although the Maven project packaging format is also an important part of the coordinates, but it is not part of a project-unique identifier. A project of groupId: artifactId: version making it a unique project; you can not have a have the same groupId, artifactId and version identification of the project.
  • packaging
    The type of project, the default is jar, after describing the output of the project package. Types of projects for the jar to produce a JAR file, type of war to produce a web application project.
  • classifier
    Rarely used the coordinates, can generally be ignored classifiers. If you want to publish the same code, but due to technical reasons, need to generate two separate components, you should use a classifier (classifier). For example, if you want to build two separate elements into a JAR, a use Java 1.4 compiler, and the other using Java 6 compiler, you can use the classifier to generate a JAR two separate components, they have the same groupId : artifactId: version combination. If your project uses local extension library, you can use the classifier for each target platform to generate a component. Classification commonly used in the packaging component source, JavaDoc or binary set.


maven has its own version of the specification, is generally defined as follows <major version>. <minor version>. <incremental version> - <qualifier>, such as 1.2.3-beta-01. To note that, maven own version of the algorithm is to determine major, minor, incremental compared with some, qualifier part of the string comparison, so be careful alpha-2 and alpha-15 the comparison between the best alpha-02 format.

maven version management time can be used in a few special strings SNAPSHOT, LATEST, RELEASE. Such as "1.0-SNAPSHOT". Various parts of the meaning and processing logic described as follows:

  • SNAPSHOT
    If a version that contains the string "SNAPSHOT", Maven will be released this component is installed or when the symbolic start to a date and time value, converted to UTC time. For example, "1.0-SNAPSHOT" in at 14:10 on May 5, 2010, when released into 1.0-20100505-141000-1.
    This word can only be used during development because, in general, the project team will often release some versions, the last actual release, in these snapshot to find a stable version for the official release, such as before the 1.4 release , there will be a series of 1.4-SNAPSHOT, but the actual release of 1.4, but also from out of a stable version.
  • LATEST
    Refers to a particular component of the latest release, this release may be a release, it could be a snapshot version, look at what specific time of the last.
  • RELEASE
    Refers to the final release.

2.6 maven part


maven maven managed the entire project is divided into several parts, one part of the source code, including source code itself, related resources, is a part of the unit test cases, other part is all the maven plug-in. For these parts, maven can independently manage them, including external dependencies.

2.7 maven dependency management


Dependency management is generally the most attractive features of using maven, this feature allows developers to code only need to focus on the direct dependence, for example, we use a spring, spring depends on the added note on it, as spring is also dependent on what their external things, maven help us get.

Notes contains any external dependencies are several elements: groupId, artifactId, version, scope, type, optional. The first three of which are necessary, their meanings are as follows:

  • groupId must
  • artifactId must
  • version must be.
    The version can be used here to represent the range of expression, such as (2.0) that> 2.0, [2.0, 3.0) that 2.0 <= ver <3.0; separated by commas between multiple conditions, such as [1,3), [ 5,7].
  • Limits the scope of scope
  • type usually occurs when the pom reference dependence, other times not
  • optional dependent on whether the optional

maven that the program's reliance on external programs with the stage and scenarios change, so the maven dependencies in a scope (scope) of the restrictions. In the maven, scope contains the following values:

  • compile (compile scope)
    compile is the default scope; If you do not provide a range, that range is a compilation of the range dependent. Compile all dependent on the range available in the classpath, and they will be packaged.
  • provided (the scope has been provided)
    provided dependent only if the JDK or a container has been provided until after the dependent. For example, if you developed a web application, you may need to build the classpath of the Servlet API can be used to compile a servlet, but you will not want to include in the packaged WAR this Servlet API; the Servlet API JAR by your application server or servlet container. Has provided scope dependencies at compile classpath (not the runtime) is available. They are not transitive, it will not be packaged.
  • runtime (run-time range)
    runtime to run and test systems rely on when needed, but not at compile time. For example, when you may only need to compile JDBC API JAR, and only run when it need a JDBC driver implementation.
  • test (test range)
    test range dependence in general do not need to compile and run, they only compile and test runs in test phase is available. Range dependence in the previous test??? Described before.
  • system (system-wide)
    range dependence and provided a similar system, but you must explicitly provide a JAR file for the local system in the path. This is done to allow the compilation based on local objects, and these objects are part of the system library. This component should be always available, Maven will not go looking for it in the warehouse. If you rely on a set system-wide scope, you must provide a systemPath element. Note that the range is not recommended (you should always try to go from a public or custom Maven repository reference dependence).


In addition, the code is a code dependent on their own, using the various maven plugins can have their own dependencies. Dependence can also be optional, such as our code does not rely on any cache, but may have to configure the hibernate cache, so the cache dependency is optional.

More than 2.8 Project Management


maven multi-project management is also very powerful. In general, maven of all requirements with a sub-project are placed into the same directory, a subdirectory for each representative of a project, such as

  • The total project /
    • The total project pom.xml pom configuration file
    • Sub 1 /
      • 1 sub-pom file pom.xml
    • Sub 2 /
      • pom.xml sub 2 pom file


Stored in accordance with this format is inheritance, all the specific sub-projects in the pom.xml inherits the contents of the total project pom, pom value of the contents of the priority sub-projects.

To set the inheritance, the first in the overall project's pom to add the following configuration

<modules>
<module> simple-weather </ module>
<module> simple-webapp </ module>
</ Modules>

Second, add in each subproject

<parent>
<groupId> org.sonatype.mavenbook.ch06 </ groupId>
<artifactId> simple-parent </ artifactId>
<version> 1.0 </ version>
</ Parent>

Can.

Of course, inheritance is not the only way to share configuration files, maven supports by reference. Reference pom way easier, add a dependent type in the pom dependency can be.

<project>
<description> This is a project requiring JDBC </ description>
...
<dependencies>
...
<dependency>
<groupId> org.sonatype.mavenbook </ groupId>
<artifactId> persistence-deps </ artifactId>
<version> 1.0 </ version>
<type> pom </ type>
</ Dependency>
</ Dependencies>
</ Project>

2.9 Properties


Users can define some attributes in maven, and then in other places with $ {xxx} is referenced. For example:

<project>
<modelVersion> 4.0.0 </ modelVersion>
...
<properties>
<var1> value1 </ var1>
</ Properties>
</ Project>
maven provides three implicit variables, used to access the system environment variables, POM information and the maven settings:
  • env
    Exposure to the operating system environment variables, such as env.PATH
  • project
    Exposed to the contents of the POM, with the dot (.) Path to reference the value of POM elements, such as $ {project.artifactId}. In addition, java system property user.dir example, also exposed here.
  • settings
    Exposure to the maven settings information can also be used dot (.) Referenced. maven the system configuration file stored in the maven installation directory, the user-related configuration files stored in ~ / .m2/settings.xml (unix) or% USERPROFILE% / .m2/settings.xml (windows) in.

2.10 maven's profile


maven profile is an important feature, which allows to automatically adapt maven external environmental changes, such as with a project in linux compile the linux version, compiled in a win win version and so on. A project can set up multiple profile, you can set up multiple at the same time the profile is activated (active) of the. Automatically activate the profile of the condition can be a variety of settings, portfolio placed in the activation node can also be directly specified by the command line. profile can also contain other content override pom configuration defines the corresponding value. If that profile is more complex set, you can move the contents of all the profiles to specific profiles.xml file, but remember and pom.xml together.

activation node was activated in common can be:

  1. os
    Determine the operating system-related parameters, which contains the following child nodes can be freely combined elements of
    • message - the message that appears after the failure of the rules
    • arch - matching cpu structure, common to x86
    • family - family of operating systems match, the common value of: dos, mac, netware, os / 2, unix, windows, win9x, os/400 etc.
    • name - the name matches the operating system
    • version - the version number matches the operating system
    • display - the operating system is detected, the information displayed
  2. jdk
    Check the jdk version, you can use that range.
  3. property
    Check the property value, the node can contain name and value of two child nodes.
  4. file
    Check the file related content, contains two child nodes: exists and missing, files were examined for the presence and absence of two cases.

3. Maven of the operation and use of


maven of the operation in two ways, one is through the mvn command line command, is to use the maven eclipse plugin. Because the operation using the eclipse maven plugin is easier to introduce here only with the mvn command line operation.

3.1 maven configuration file


maven main executable for the mvn.bat, linux under mvn.sh, these two procedures are simple, their common purpose is to collect some of the parameters, then use java.exe to run maven in the Main function. maven also need a configuration file, called settings.xml, it in two places, a maven installation directory is the conf directory for all users to use the maven of the work, we called the main configuration file, another placed in% USERPROFILE% / .m2/settings.xml, we become the user profile, only the current user, and can cover the contents of the main configuration file parameters. There is a project-level configuration information, and store it in the management of each of a maven project directory, called pom.xml, mainly used for configuration items related to some of the content, of course, if necessary, the user can write in the pom some configuration, covers the configuration file and set the parameters of the user profile content.

In general, settings such as the repository file is configured like a global library path information, specifically refer to the official website of the article .

3.2 Creating a New Project


To create a new maven project, our project we need to specify the number of necessary elements is to coordinate the several elements maven products: groupId, artifactId, if you wish, you can also specify the version and package name. We look at the creation of a simple command:

d: \ work \ temp> mvn archetype: create-DgroupId = com.abc-DartifactId = product1-DarchetypeArtifactId = maven-archetype-webapp

First look at where the command line arguments to pass structure, strange-D parameter = value approach is java.exe in the manner required. This command creates a web project directory structure is a standard maven structure, as follows:

D:.
└ ─ mywebapp
│ pom.xml

└ ─ src
└ ─ main
├ ─ resources
└ ─ webapp
│ index.jsp

└ ─ WEB-INF
web.xml

We should note that the layout of the directory structure here is actually determined by the parameters archetypeArtifactId, because there is incoming maven-archetype-webapp if we pass the other would create a different structure, the default value maven-archetype- quickstart, interested readers can refer to more detailed list , I put a list of some commonly used here:

Artifact Group Version Repository Description
maven-archetype-j2ee-simple org.apache.maven.archetypes A simple J2EE Java application
maven-archetype-marmalade-mojo org.apache.maven.archetypes A Maven plugin development project using marmalade
maven-archetype-plugin org.apache.maven.archetypes A Maven Java plugin development project
maven-archetype-portlet org.apache.maven.archetypes A simple portlet application
maven-archetype-profiles org.apache.maven.archetypes
maven-archetype-quickstart org.apache.maven.archetypes
maven-archetype-simple org.apache.maven.archetypes
maven-archetype-site-simple org.apache.maven.archetypes A simple site generation project
maven-archetype-site org.apache.maven.archetypes A more complex site project
maven-archetype-webapp org.apache.maven.archetypes A simple Java web application
maven-archetype-har net.sf.maven-har 0.9 Hibernate Archive
maven-archetype-sar net.sf.maven-sar 0.9 JBoss Service Archive

We can refer to more detailed archetype: create help and archtype reference information .

3.3 maven multi-project management


Maven multi-project management is one of the main characteristics for a large-scale projects with maven to manage complex dependencies between them, is better. maven project configuration between two: inheritance and reference relations.
The default directory structure to maven pom inheritance to set that lower directory inherit the default parent directory pom pom. To set the relationship between the two is very simple, the higher pom set as follows:

<modules>
<module> ABCCommon </ module>
<module> ABCCore </ module>
<module> ABCTools </ module>
</ Modules>

To remember is that, where the module is the directory name, not the sub-project artifactId. Sub-projects set up as follows:

<parent>
<groupId> com.abc.product1 </ groupId>
<artifactId> abc-product1 </ artifactId>
<version> 1.0.0-SNAPSHOT </ version>
</ Parent>
<artifactId> abc-my-module2 </ artifactId>
<packaging> jar </ packaging>

This correlation between it up, inheritance relationship set is completed, all the contents of the configuration of the parent project in the sub-projects will take effect automatically unless the configuration of sub-projects have the same coverage. If you do not like progressive layers of the directory structure to implement inheritance, you can also add in the parent <relativePath> .. / a-parent / pom.xml </ relativePath> parent project to develop a relative directory. Inheritance is often used in the extraction of common features of the project, through the extraction of public properties, can significantly reduce the workload of sub-configuration.

Reference relationship is another way to reuse, maven configure the reference relationship is also very simple, adding a type of dependency to pom.

<dependency>
<groupId> org.sonatype.mavenbook </ groupId>
<artifactId> persistence-deps </ artifactId>
<version> 1.0 </ version>
<type> pom </ type>
</ Dependency>

But both the parent project or project reference, these projects must use mvn install or mvn deploy installation to the local library. Otherwise, it will rely on the report did not find, eclipse will compile time error.

Need to highlight the reuse process, the parent pom project can be defined dependencyManagement nodes, which store dependencies, but this dependency is defined, does not really have an effect, if you want to use this sub-project dependencies, you can add in the dependency itself a simplified reference

<dependency>
<groupId> org.springframework </ groupId>
<artifactId> spring </ artifactId>
</ Dependency>

This method avoids flying version of the case.

3.4 Installing library files to the maven repository


Usually used in the maven installation in library functions, one is common to use hibernate jmx library, but because the sun's license restrictions, it can not be included directly in the repository. So we use the mvn command to install the jar in our local repository

mvn install: install-file-DgroupId = com.sun.jdmk-DartifactId = jmxtools-Dversion = 1.2.1-Dpackaging = jar-Dfile = / path / to / file

If we want to install it into the company's repository, you need to use the command

mvn deploy: deploy-file-DgroupId = com.sun.jdmk-DartifactId = jmxtools-Dversion = 1.2.1-Dpackaging = jar-Dfile = / path / to / file-Durl = http://xxx.ss.com/ sss.xxx-DrepositoryId = release-repo

For our project output, if you need to place the company in the repository, it can be achieved by configuring the pom

<distributionManagement>
<repository>
<id> mycompany-repository </ id>
<name> MyCompany Repository </ name>
<url> scp: / / repository.mycompany.com/repository/maven2 </ url>
</ Repository>
</ DistributionManagement>

Scp method used here to submit libraries, there are other ways you can use, please refer to faq section. Then remember to add in your settings.xml this content

<Settings xmlns = "http://maven.apache.org/SETTINGS/1.0.0"
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation = "http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd ">
...
<servers>
<server>
<id> mycompany-repository </ id>
<username> jvanzyl </ username>
<! - Default value is ~ / .ssh / id_dsa ->
<privateKey> / path / to / identity </ privateKey>
<passphrase> my_key_passphrase </ passphrase>
</ Server>
</ Servers>
...
</ Settings>

3.5 maven variables


maven a lot of variables defined attributes, see here http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide

  1. Built-in properties
    • $ {Basedir} represents the directory containing pom.xml
    • $ {Version} equivalent to $ {project.version} or $ {pom.version}
  2. Pom / Project properties
    All pom elements can be used in the project. Prefix for reference, the following are some commonly used
    • $ {Project.build.directory} results in the path to your "target" dir, this is the same as $ {pom.project.build.directory}
    • $ {Project.build. OutputD irectory} results in the path to your "target / classes" dir
    • $ {Project.name} refers to the name of the project.
    • $ {Project.version} refers to the version of the project.
    • $ {Project.build.finalName} refers to the final name of the file created when the built project is packaged
  3. With the local user to set all the settings in the settings.xml are available through the settings. Prefix reference
    • $ {Settings.localRepository} refers to the path of the user's local repository.
    • $ {Maven.repo.local} also works for backward compatibility with maven1??
  4. Environment variable system environment variables through the env. Prefix reference
    • $ {Env.M2_HOME} returns the Maven2 installation path.
    • $ {Java.home} specifies the path to the current JRE_HOME environment use with relative paths to get for example:
      <jvm> $ {java.home} .. / bin / java.exe </ jvm>
  5. all java JVM system properties defined in java system properties.
  6. User defined in the pom custom properties

    <project>
    ...
    <properties>
    <my.filter.value> hello </ my.filter.value>
    </ Properties>
    ...
    </ Project>

    The reference to $ {my.filter.value} get value of hello
  7. Superior engineering variables in the parent pom project variables with the prefix $ {project.parent} references the higher version of the project can be such a reference: $ {parent.version}.

3.6 maven use


We already know a lot of maven predefined phase (phase), each plug are attached to the stage, and when entering some stage, called plug-ins to run these related functions. Let's look at the complete life cycle of maven:

Life Cycle Phase Description
validate Verify that the project is correct and complete in order to build all the necessary information is available
generate-sources Generate all the need to include in the compilation process of source code
process-sources Processing source code, such as filtering certain value
generate-resources Included in the package to generate all the necessary resources to process the file
process-resources Copy and processing the resource file to the destination directory, ready to pack
compile Compile project source code
process-classes Compiled files after processing, such as the Java class byte-code enhancement (bytecode enhancement)
generate-test-sources All included in the test generation process of compiling a test source
process-test-sources Processing the test source, such as filtering certain value
generate-test-resources Resources needed to generate the test file
process-test-resources Copy and process the test file to test the target directory resource
test-compile Compile the test source code to the test destination directory
test Suitable unit testing framework to run tests. These tests should not require the code be packaged or released
prepare-package Before packing in a real implementation of the necessary operations to prepare for packing. This usually results in a package of expanded processed version (will be implemented in Maven 2.1 +)
package Compiled code will be packaged into a distributable format, such as JAR, WAR, or EAR
pre-integration-test Perform some integration testing is required before running the action. Such as the need to establish an integrated test environment
integration-test If necessary, process and publish packages to the integrated test environment that can run
post-integration-test Perform some integration testing is required after running the action. Such as cleaning up an integrated test environment.
verify Perform all the checks, verify the package is effective, meet quality standards
install Installation package to a local warehouse, other items to prepare for local use as a dependent
deploy Copy the final package to the remote repository, shared with other developers and projects (usually related to an official release)

maven core plugins list can refer to http://maven.apache.org/plugins/index.html . Here are just a few common plug-ins and a few configuration parameters:

  1. clean plug-in
    Contains only one goal called clean: clean, clean up the build time to create the file. The default position is to clean up a few variables as the path specified project.build.directory, project.build.outputDirectory, project.build.testOutputDirectory, and project.reporting.outputDirectory.
  2. compiler plug-in
    Contains two goal, namely, compiler: compile and the compiler: testCompile. You can see here two specific parameters: compile , testCompile .
  3. surefire plugin
    Plug-ins run unit test cases, and to generate reports. Contains a goal for the surefire: test. The main parameters used to specify test cases testSourceDirectory directory, reference the full usage help
  4. jar
    Responsible for the project output packaged in a jar file. Contains two goal, namely jar: jar, jar: test-jar. Responsible for two goal or testClassesDirectory from classesDirectory get all the resources, then the output jar file to the outputDirectory.
  5. war
    Responsible for packing into a war file. Common goal there is war: war, is responsible from warSourceDirectory (default $ {basedir} / src / main / webapp) to the outputDirectory all resources in the package.
  6. resources
    The reproduction of various resource files, commonly used goal with resources: resources, responsible for resource files to the outputDirectory, the default is $ {project.build.outputDirectory}.
  7. install
    Responsible for the project output (install: install) or a specified file (install: install-file) added to the native library% USERPROFILE% / .m2/repository in. Can install: help for help.
  8. deploy
    Responsible for the project output (deploy: deploy) or a specified file (deploy: deploy-file) added to the company library.
  9. site
    All documents generated the project site, generated by default for apache web interface similar to the project site, but the document format used doxia written, does not currently support docbook, with the need to support other plug-ins. It should be noted that, in the maven 2.x series and maven3.x the site command processing is different in the old version, use mvn site command can generate all reports in the reporting node, but in maven3 in, reporting out of date , take these as the maven-site-plugin's configuration content Caixing. Details can refer to http://www.wakaleo.com/blog/292-site-generation-in-maven-3

4. Maven use Q


In addition to following a few faq entries, and some faq can refer to

  1. maven own FAQ

Brothers If there are other questions, please question thread!

4.1 Dependencies

1) Q: how to add a dependency to delete?

A: directly in the pom file to add a dependency node, if you want to remove the dependence on the corresponding dependency node can be deleted.

2) Q: How to disable a dependency? Such as used in the project libA dependent on a library version 1.0, libB a library since version 2.0, now want a unified version 2.0, version 1.0, how to get rid of dependence?

A: The exclusion can be.

<dependency>
<groupId> org.hibernate </ groupId>
<artifactId> hibernate </ artifactId>
<version> 3.2.5.ga </ version>
<exclusions>
<exclusion>
<groupId> javax.transaction </ groupId>
<artifactId> jta </ artifactId>
</ Exclusion>
</ Exclusions>
</ Dependency>
3) Q: I have some jar files have to rely on, but I do not want the jar to the repository mvn install to go, how to do the configuration?

A: Add a special dependency, the use of system type, as follows:

<dependency>
<groupId> com.abc </ groupId>
<artifactId> my-tools </ artifactId>
<version> 2.5.0 </ version>
<type> jar </ type>
<scope> system </ scope>
<systemPath> $ {basedir} / lib/mylib1.jar </ systemPath>
</ Dependency>
 But remember, publishing does not copy the jar. Requires manual configuration, and other project Depends on this project when , Will report a warning. If there are no special requirements , Publish proposed direct registration to repository.

4) Q: In eclipse maven builder to use both the environment and the eclipse builder, and set the project dependencies after, why not find the artifact will be compiled error, but directly using the command line mvn build everything is fine?

A: In the project properties java build path to remove the dependencies on other project, set directly in the pom dependencies can be

<! - Depends on other items ->
<dependency>
<groupId> com.abc.project1 </ groupId>
<artifactId> abc-project1-common </ artifactId>
<version> $ {project.version} </ version>
</ Dependency>
In addition, to ensure that no other errors.
5) Q: I want the output jar file contains all the dependencies automatically

A: You can use the assembly plugin.

<plugin>
<artifactId> maven-assembly-plugin </ artifactId>
<configuration>
<descriptorRefs>
<descriptorRef> jar-with-dependencies </ descriptorRef>
</ DescriptorRefs>
</ Configuration>
</ Plugin>
 

6) Q: My test cases test cases depend on other projects, how to set?

A: maven itself, when released, can publish a simple jar, can also release xxx-tests.jar and xxx-javadoc.jar (often in the repository we can see similar things). A project of our own can do to output the following set test.jar

<! - Code for the test made a jar ->
<plugin>
<groupId> org.apache.maven.plugins </ groupId>
<artifactId> maven-jar-plugin </ artifactId>
<executions>
<execution>
<goals>
<goal> test-jar </ goal>
</ Goals>
</ Execution>
</ Executions>
</ Plugin>
Then need to reference other projects in B set to do the following dependency

<dependency>
<groupId> com.abc.XXX </ groupId>
<artifactId> Project A </ artifactId>
<version> $ {project.version} </ version>
<type> test-jar </ type>
<scope> test </ scope>
</ Dependency>
7) How to make the project dependent jar maven copy into the WEB-INF/lib directory?


8) I just updated my library of nexus, but I can not find my m2eclipse eclipse using the new library

Modify the pom.xml file, the jar dependencies in the older version can be directly modified for the new version.

9) I want the latest version of the jar is not in the maven central repository, how do I do?

Will depend on the files installed to the local library, complete with the following command:

mvn install:install-file
  -Dfile=<path-to-file>
  -DgroupId=<group-id>
  -DartifactId=<artifact-id>
  -Dversion=<version>
  -Dpackaging=<packaging>
  -DgeneratePom=true

Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar     
10)

4.2 Variables

1) Q: How to use variable substitution? Project uses a configuration file such as jdbc.properties some pom variables, how to release that contains the real content of the final outcome document?

A: The use of filtering resources, such as:

<project>
...
<properties>
<jdbc.driverClassName> com.mysql.jdbc.Driver </ jdbc.driverClassName>
<jdbc.url> jdbc: mysql: / / localhost: 3306/development_db </ jdbc.url>
<jdbc.username> dev_user </ jdbc.username>
<jdbc.password> s3cr3tw0rd </ jdbc.password>
</ Properties>
...
<build>
<resources>
<resource>
<directory> src / main / resources </ directory>
<filtering> true </ filtering>
</ Resource>
</ Resources>
</ Build>
...
<profiles>
<profile>
<id> production </ id>
<properties>
<jdbc.driverClassName> oracle.jdbc.driver.OracleDriver </ jdbc.driverClassName>
<jdbc.url> jdbc: oracle: thin: @ proddb01: 1521: PROD </ jdbc.url>
<jdbc.username> prod_user </ jdbc.username>
<jdbc.password> s00p3rs3cr3t </ jdbc.password>
</ Properties>
</ Profile>
</ Profiles>
</ Project>
2) Q: maven-svn-revision-number-plugin plug-in instructions

A: maven-svn-revision-number-plugin can be obtained from the SVN version, and turn it into an environment variable, or the profile used by other plug-ins, detailed help here . General and resource use both the filter mechanism

<plugins>
<plugin>
<groupId> com.google.code.maven-svn-revision-number-plugin </ groupId>
<artifactId> maven-svn-revision-number-plugin </ artifactId>
<version> 1.3 </ version>
<executions>
<execution>
<goals>
<goal> revision </ goal>
</ Goals>
</ Execution>
</ Executions>
<configuration>
<entries>
<entry>
<prefix> prefix </ prefix>
</ Entry>
</ Entries>
</ Configuration>
</ Plugin>
</ Plugins>

This code is responsible for the content of the resource file, replace the appropriate content

repository = $ {prefix.repository}
path = $ {prefix.path}
revision = $ {prefix.revision}
mixedRevisions = $ {prefix.mixedRevisions}
committedRevision = $ {prefix.committedRevision}
status = $ {prefix.status}
specialStatus = $ {prefix.specialStatus}
3) Some of my unit test program for errors, how to ignore the test procedure?

There are several ways to skip unit testing can be achieved step one is to increase the mvn command line parameters-Dmaven.test.skip = true or-DskipTests = true; another surefire plugin is to add parameters, as follows:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.8</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
4) If you want to run a single test, can be achieved?

Can run when the add command-line parameters-Dtest = MyTest to which MyTest is the need to run the unit test name, but need not include the package section.

4.3 Compile

1) Q: How to assign parameters to the plug-in? For example, I have to set some compilation parameters

A: The following set of code compiler java1.5

<project>
...
<build>
...
<plugins>
<plugin>
<artifactId> maven-compiler-plugin </ artifactId>
<configuration>
<source> 1.5 </ source>
<target> 1.5 </ target>
</ Configuration>
</ Plugin>
</ Plugins>
...
</ Build>
...
</ Project>
To set the parameters of other plug-ins can also refer to the corresponding plug-in help
2) Q: My directory is non-standard directory structure, how to set up so that maven support?

A: The specified source directory and test-source directory.

<build>
<directory> target </ directory>
<sourceDirectory> src </ sourceDirectory>
<scriptSourceDirectory> js / scripts </ scriptSourceDirectory>
<testSourceDirectory> test </ testSourceDirectory>
<outputDirectory> bin </ outputDirectory>
<testOutputDirectory> bin </ testOutputDirectory>
</ Build>
This example source code set to the src directory, the test code in the test directory, so the output to the bin directory. Here we must note, directory set to bin directory if you are, then, maven package will cause an infinite loop when, because the directory is the storage of all places, the definition included by default outputDirectory directory included.
3) My source code is UTF8 format, how can I specify in maven?

You can set a variable

<project>
...
<properties>
<project.build.sourceEncoding> UTF-8 </ project.build.sourceEncoding>
</ Properties>
...
</ Project>
{Color: blue} given above is the official solution, but after trying this only affects the resource processing time encoding {color}, a truly useful configuration is as follows:
{code:xml}
<build>
  ...
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <encoding>UTF-8</encoding>
      </configuration>
    </plugin>
  ...
</build>
{code}
Q: My project in addition to main / java directory, but also added other c + + directory, you want to be compiled, how do?
A: The use of native plug-in, the specific configuration information [http://mojo.codehaus.org/maven-native/native-maven-plugin/]
{code:xml}
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>native-maven-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
</plugin>    
{code}
Q: I want to project all the dependent jar are packaged together, how do?
A: First, modify the maven configuration file, to the maven-assembly-plugin to add a jar-with-dependencies of the description.
{code:xml}
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
{code}

Package can then use the command:
mvn assembly:assembly
Q: I want main / scripts packaged with the release in the content, how to do?
A: pom additional resources in the configuration directory. If necessary, you can also specify the output location
{code:xml}
<build>
  ...
  <resources>
    <resource>
      <filtering>true</filtering>
      <directory>src/main/command</directory>
      <includes>
        <include>run.bat</include>
        <include>run.sh</include>
      </includes>
      <targetPath>/abc</targetPath>
    </resource>
    <resource>
      <directory>src/main/scripts</directory>
    </resource>
  </resources>
  ...
</build>
{code}
Resource Directory
Q: I have multiple source directories, but only supports a main src maven and a test src, how to do?
A: The use of another plug-in, and modeled the following configuration pom
{code:xml}
<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/config/java</source>
                <source>src/main/java</source>
                <source>src/member/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
{code}
Q: My part of the source code directory, the file I do not want maven build, how to do?
A: Use a maven plugin, and then use the includes and excludes. Similarly, processing resources can also be filtered.
{code:xml}
<build>
  <sourceDirectory>http://www.cnblogs.com/src/java</sourceDirectory>
  <plugins>
    <plugin>
      <groupId>com.sun.enterprise</groupId>
      <artifactId>hk2-maven-plugin</artifactId>
      <configuration>
        <includes>
          <include>com/sun/logging/LogDomains.*</include>
          <include>com/sun/enterprise/util/OS.java</include>
          <include>com/sun/enterprise/util/io/FileUtils.java</include>
          <include>com/sun/enterprise/util/zip/**</include>
          <include>com/sun/enterprise/util/i18n/**</include>
          <include>com/sun/enterprise/deployment/backend/IASDeploymentException.java</include>
        </includes>
        <excludes>
          <exclude>com/sun/enterprise/config/ConfigBeansFactory.java</exclude>
          <exclude>com/sun/enterprise/config/clientbeans/**</exclude>
        </excludes>
      </configuration>
    </plugin>
  </plugins>
  <resources>
    <resource>
      <directory>http://www.cnblogs.com/src/java</directory>
      <includes>
        <include>**/*.properties</include>
      </includes>
    </resource>
  </resources>
</build>
{code}
Q: My project is a project consisting of pure html, no java code, how to skip the compilation process?
A: The configuration is as follows
{code:xml}
<build>
  <sourceDirectory>src/java</sourceDirectory>
  <plugins>
    <plugin>
    <groupId>com.sun.enterprise</groupId>
    <artifactId>hk2-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>
{code}
Q: I work in the use hibernate, like automatically generated at compile time ddl, how to do?
A: Adding plug-
hibernate3-maven-plugin
, in accordance with the following configuration:
{code:xml}
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>hibernate3-maven-plugin</artifactId>
          <version>2.1</version>
          <configuration>
            <components>
              <component>
                <name>hbm2ddl</name>
                <implementation>annotationconfiguration</implementation>
              </component>
            </components>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>hsqldb</groupId>
              <artifactId>hsqldb</artifactId>
              <version>${hsqldb.version}</version>
            </dependency>
          </dependencies>
        </plugin>
{code}
Q: Can I use maven support eclipse RCP project?

A: Yes, you can use the plug-Tycho, details can be found here [ http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-bundles/ ].

 <plugin>
  <groupid>org.sonatype.tycho</groupid>
  <artifactid>target-platform-configuration</artifactid>
  <version>0.7.0</version>
  <configuration>
    <resolver>p2</resolver>
  </configuration>
</plugin>
 In addition, the incumbent pde-maven-plugin Do not use, had not seen for years update .

4.4 ant interaction

1) How to run maven ant script compile time?

The use of specialized antrun plug-in, and join in the ant target labels within the code

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <phase> <!--  Life cycle stage  --> </phase>
            <configuration>
              <target>
                <!--  Join target internal code  -->
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

2) How to reference the script in the ant the maven classpath?

to each according to Lai Dousheng maven into a property in the format "groupId: artifactId [: classifier]: type", for example, if you look at an example to show the dependence of org.apache.common-util jar file path

<echo message="Dependency JAR Path: ${org.apache:common-util:jar}"/> 

In addition, maven has four predefined reference to the classpath, they are

  • maven.compile.classpath
  • maven.runtime.classpath
  • maven.test.classpath
  • maven.plugin.classpath

3) How to use the antrun plugin to run an external build file?

Very simple, direct instruction in the antrun can use the ant inside, as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
                <target>
                    <!--  Classpath passed built to both external ant File  -->
                    <property name="compile_classpath" refid="maven.compile.classpath"/>
                    <property name="runtime_classpath" refid="maven.runtime.classpath"/>
                    <property name="test_classpath" refid="maven.test.classpath"/>
                    <property name="plugin_classpath" refid="maven.plugin.classpath"/>
    
                    <ant antfile="${basedir}/build.xml">
                        <target name="test"/>
                    </ant>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Q: How to use the maven ant function?
A: Use the ant [maven task | http://maven.apache.org/ant-tasks/index.html], but only ant 1.6 and above only support jdk 1.5 environment.

h4. test-related

Q: how to ignore the results of a phase? Such as unit tests need not be all right
A: increase testFailureIgnore parameters to the plug, and set to false. If you want to shield the stage, then use
<skip>true</skip>
{code:xml}
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <testFailureIgnore>true</testFailureIgnore>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
{code}
Q: How do I add maven PMD, CheckStyle, JDepend such checking?
A: Add PMD inspection, the following code to add the node if
reporting
performed in
mvn site
if
build
node to add, then run automatically at build time checks. Detailed configuration information [pmd plugin instructions | http://maven.apache.org/plugins/maven-pmd-plugin/]
{code:xml}
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>2.5</version>
      </plugin>
    </plugins>
{code}
adding checkstyle checks, detailed configuration information [checkstyle plug-in instructions | http://maven.apache. org / plugins / maven-checkstyle-plugin /], the same attention placed on the reporting and build node difference (all plug-ins should also note that the report class):
{code:xml}
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.5</version>
      </plugin>
{code}
added support simian, simian similarity check is a tool to support code , there are maven plugin, also checkstyle plug-ins. It not only can check the java, and even support text file check. For more help refer to [here | http://www.redhillconsulting.com.au/products/simian/]. The maven plugin in simian [here | http://mojo.codehaus.org/simian-report-maven-plugin/introduction.html]
{code:xml}
      <build>
         <plugins>
            <plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>simian-maven-plugin</artifactId>
               <version>1.6.1</version>
            </plugin>
         </plugins>
         ...
      </build>
{code}
join jdepend inspection, detailed configuration information [jdepend instructions | http://mojo.codehaus .org / jdepend-maven-plugin /],
{code:xml}
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jdepend-maven-plugin</artifactId>
        <version>2.0-beta-2</version>
      </plugin>
{code}
join findbugz inspection, detailed configuration information [findbugz instructions | http://mojo.codehaus.org/findbugs-maven-plugin/usage.html],
{code:xml}
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.0.1</version>
      </plugin>
{code}
added javadoc generation, detailed configuration information [javadoc usage | http://maven.apache.org/plugins/maven-javadoc-plugin/usage.html]
{code:xml}
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          ...
        </configuration>
      </plugin>
{code}
join jxr support, JXR generated java code is a cross-reference and source code tool for html format detailed configuration information refer to [jxr usage | http://maven.apache.org/plugins/maven-jxr-plugin/]. Note, jxr no need to run in the build phase.
{code:xml}
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>2.1</version>
      </plugin>
    </plugins>
  </reporting>
{code}
join Cobertura support, it is a code coverage tool can be used to evaluate the source code with the corresponding ratio of the test. For more help [here | http://mojo.codehaus.org/cobertura-maven-plugin/index.html]. Another feature similar software [EMMA | http://emma.sourceforge.net/samples.html], detailed help [here | http://mojo.codehaus.org/emma-maven-plugin/usage. html]. More articles in the two products [here | http://www.topcoder.com/tc?module=Static&d1=features&d2=030107], individuals tend to be, because the indicators are not given the same reference has .
{code:xml|title=Cobertura }
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <check>
            <branchRate>85</branchRate>
            <lineRate>85</lineRate>
            <haltOnFailure>true</haltOnFailure>
            <totalBranchRate>85</totalBranchRate>
            <totalLineRate>85</totalLineRate>
            <packageLineRate>85</packageLineRate>
            <packageBranchRate>85</packageBranchRate>
            <regexes>
              <regex>
                <pattern>com.example.reallyimportant.*</pattern>
                <branchRate>90</branchRate>
                <lineRate>80</lineRate>
              </regex>
              <regex>
                <pattern>com.example.boringcode.*</pattern>
                <branchRate>40</branchRate>
                <lineRate>30</lineRate>
              </regex>
            </regexes>
          </check>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>clean</goal>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
{code}
{code:xml|title=EMMA}
  <reporting>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>emma-maven-plugin</artifactId>
        <version>1.0-alpha-3-SNAPSHOT</version>
      </plugin>
      ...
    </plugins>
    ...
  </reporting>
{code}
add javaNCSS plug-in, it is a java code metrics tool, detailed information in [here | http://mojo.codehaus.org/javancss-maven-plugin/].
{code:xml}
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>javancss-maven-plugin</artifactId>
        <version>2.0-beta-2</version>
      </plugin>
    </plugins>
  </reporting>
{code}
h4. profile related
Q: profile can be set to a variable does not exist under the conditions of activation?
A: Use! Prefix, see Example:
{code:xml}
<activation>
        <property>
          <name>!environment.type</name>
        </property>
      </activation>
{code}
h4. Deployment-related
Q: Other ways to deploy to the server and configured with how?
A: This article is taken from [http://blog.csdn.net/zyxnetxz/archive/2009/05/18/4199348.aspx] {panel} * Distribution Management * used to configure the distribution management, configure the product release information, the main for publishing, said after running mvn deploy the location you want to publish * # configuration to the file system
{code:xml}
<distributionManagement>
  <repository>
    <id>proficio-repository<id>
    <name>Proficio Repository<name>
    <url>file://${basedir}/target/deploy<url>
  <repository>
<distributionManagement>
{code}
* # use ssh2 configuration
{code:xml}
<distributionManagement>
  <repository>
    <id>proficio-repository<id>
    <name>Proficio Repository<name>
    <url>scp://sshserver.yourcompany.com/deploy<url>
  <repository>
<distributionManagement>
{code}
* # use sftp configuration
{code:xml}
<distributionManagement>
  <repository>
    <id>proficio-repositoryi<d>
    <name>Proficio Repository<name>
    <url>sftp://ftpserver.yourcompany.com/deploy<url>
  <repository>
<distributionManagement>
{code}
* # ssh configuration to use external compiler extension to specify the external use of wagon ssh offer to provide your files to the appropriate remote server.
{code:xml}
<distributionManagement>
  <repository>
    <id>proficio-repository<id>
    <name>Proficio Repository<name>
    <url>scpexe://sshserver.yourcompany.com/deploy<url>
  <repository>
<distributionManagement>
<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon<groupId>
      <artifactId>wagon-ssh-external<artifactId>
      <version>1.0-alpha-6<version>
    <extension>
  <extensions>
<build>
{code}
* # using ftp configuration
{code:xml}
<distributionManagement>
  <repository>
    <id>proficio-repository<id>
    <name>Proficio Repository<name>
    <url>ftp://ftpserver.yourcompany.com/deploy<url>
  <repository>
<distributionManagement>
<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagongroupId>
      <artifactId>wagon-ftpartifactId>
      <version>1.0-alpha-6version>
    <extension>
  <extensions>
<build>
{code}
{panel} h4. plug-in configuration
Q: I use the maven output site, how to set the output to utf8 encoding?
A: Configure encoding settings
{code:xml}
...
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <version>2.0-beta-6</version>
    <configuration>
      <outputEncoding>UTF-8</outputEncoding>
    </configuration>
  </plugin>
  ...
{code}
site plug
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Arch-05-13-maven Frequently Asked Questions

  • Firebug Guide (four) --- how to use the Firebug command line API to provide debugging js procedures (below)

    Introduction: Firebug command line are in one of the most useful features. If you have been using Visual Studio (referred to as VS) the experience of development projects, they should know you in the use of VS debugging procedures, "the immediate win

  • Ruby in the meaning of keywords

    1, break out of the cycle when the layer 2, next neglect the remainder of the cycle to begin the next cycle 3, redo a fresh start cycle, or the beginning of this first 4, retry to start the loop 5, $ array <<value to value as an array element add an

  • Understanding of JavaScript closures

    Understanding of JavaScript closures To become advanced JavaScript programmers, it is necessary to understand the closure. In this paper, ECMA 262 specification explain the closure of the internal working mechanism for JavaScript programmers understanding

  • js bind some of the ways in case notes

    Read some information online and found that some have compared several of the cow: the john resig Flexible Javascript Events (The code, itself, is very short and simple - only 15 lines long: ) dean.edwards expressed their views: My solution is very d ...

  • ajax package (create, call) Example

    1.share.js function MyAjax (url) ( this.url = url; this.xmlHttp = (); ); MyAjax.prototype.createXMLHttpRequest = function () ( if (window.XMLHttpRequest) ( this.xmlHttp = new XMLHttpRequest (); ) Else if (window.ActiveXObject) ( this.xmlHttp = new Ac ...

  • Eclipse to run using the specified JVM m2eclipse plugin can not find tools.jar

    Used the m2eclipse plug-ins using struts2 when com.sun necessary to rely on the default-tools.jar, specifically because at the struts-annotations bag designated default-tools.jar <profile> <id> default-tools.jar </ id> <activatio ...

  • Maven 2.0: Compile. Test. Deployment. Run

    <url> http://maven.apache.org </ url> <dependencies> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 3.8.1 </ version> <scope> test </ scope> <

  • Professional IT management talent required ability Ten

    Technical article ] [IT168 As an IT technical staff, that no one person is willing to Forever in the bottom of the preparation procedure or to do simple maintenance. After a period of technology and the accumulation of experience, a lot of people are ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries