{"id":4348,"date":"2012-02-20T17:18:19","date_gmt":"2012-02-20T22:18:19","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=4348"},"modified":"2020-11-05T12:59:22","modified_gmt":"2020-11-05T17:59:22","slug":"maven-2","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=4348","title":{"rendered":"Maven 2 Overview"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Install\">Install<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Overview\">Overview<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Default_Local_Repository\">Default Local Repository<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Life_Cycle_Phases\">Life Cycle Phases<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Maven_Plugins\">Maven Plugins<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Generate_a_List_of_Archetypes\">Generate a List of Archetypes<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Copy_a_Jar_File_to_Local_Repository\">Copy a Jar File to Local Repository<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Maven_Help\">Maven Help<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Site_Report\">Site Report<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Resources\">Resources<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Project_Dependencies\">Project Dependencies<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Project_Scope\">Project Scope<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Dependency_Version_Range\">Dependency Version Range<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#dependencyManagement\">dependencyManagement<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Project_Coordinates\">Project Coordinates<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Project_Inheritance\">Project Inheritance<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Group_Dependencies\">Group Dependencies<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Inheritance_or_Multi-Module_Composition\">Inheritance or Multi-Module Composition<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#The_Build_Lifecycle\">The Build Lifecycle<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Clean_Lifecycle\">Clean Lifecycle<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Default_Lifecycle\">Default Lifecycle<\/a>\n\t\t\t\t<ol class='toc-odd level-3'>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Sources\">Sources<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Resources_1\">Resources<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Test\">Test<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Package\">Package<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Integration_Test\">Integration Test<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Install_and_Deploy\">Install and Deploy<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t<\/ol>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Site_Lifecycle\">Site Lifecycle<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Packaging_Specific_Lifecycles\">Packaging Specific Lifecycles<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Common_Lifecycle_Goals\">Common Lifecycle Goals<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Process_Resources\">Process Resources<\/a>\n\t\t\t\t<ol class='toc-odd level-3'>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Resource_Filtering_Token_Replacement\">Resource Filtering (Token Replacement)<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"#Multiple_Resource_Directories\">Multiple Resource Directories<\/a>\n\t\t\t\t\t<\/li>\n\t\t\t\t<\/ol>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Compile\">Compile<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Sample_Webapp_Project\">Sample Webapp Project<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Install\"><h2>Install<\/h2><\/span>\n<p>* Download Maven, e.g. <a href=\"http:\/\/www.apache.org\/dyn\/closer.cgi\/maven\/binaries\/apache-maven-2.2.1-bin.zip\">apache-maven-2.2.1-bin.zip<\/a>, from Maven download site: <a href=\"http:\/\/maven.apache.org\/download.html\">http:\/\/maven.apache.org\/download.html<\/a><br \/>\n* Unzip content into a local directory, e.g. <em>C:\\prog<\/em><br \/>\n* Create an environment variable called <strong>MAVEN_HOME<\/strong> and point it to where maven was unzipped, e.g. <em>C:\\prog\\apache-maven-2.2.1<\/em><br \/>\n* Add <strong>%MAVEN_HOME%\\bin<\/strong> to <em>PATH<\/em><br \/>\n* Run <strong>mvn -v<\/strong> to verify install<\/p>\n<pre lang=\"bash\">\r\nmvn -v\r\nApache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)\r\nJava version: 1.6.0_25\r\nJava home: C:\\Program Files\\Java\\jdk1.6.0_25\\jre\r\nDefault locale: en_US, platform encoding: Cp1252\r\nOS name: \"windows 7\" version: \"6.1\" arch: \"amd64\" Family: \"windows\"\r\n<\/pre>\n<span id=\"Overview\"><h2>Overview<\/h2><\/span>\n<span id=\"Default_Local_Repository\"><h3>Default Local Repository<\/h3><\/span>\n<p>* Default local repository: home_dir\/<em>.m2\/repository<\/em>, e.g. <em>C:\\Users\\jli\\.m2\\repository<\/em><\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/02\/maven_localrepodir.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/02\/maven_localrepodir-229x300.jpg\" alt=\"\" title=\"maven_localrepodir\" width=\"229\" height=\"300\" class=\"aligncenter size-medium wp-image-4349\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/02\/maven_localrepodir-229x300.jpg 229w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/02\/maven_localrepodir.jpg 468w\" sizes=\"auto, (max-width: 229px) 100vw, 229px\" \/><\/a><\/h6><\/span>\n<p>* Local repository can be configured in <em>conf\/settings.xml<\/em> file:<\/p>\n<pre lang=\"xml\">\r\n  <!-- localRepository\r\n   | The path to the local repository maven will use to store artifacts.\r\n   |\r\n   | Default: ~\/.m2\/repository\r\n  <localRepository>\/path\/to\/local\/repo<\/localRepository>\r\n  -->\r\n<\/pre>\n<span id=\"Life_Cycle_Phases\"><h3>Life Cycle Phases<\/h3><\/span>\n<p><strong>validate, generate-sources, process-sources, generate-resources, process- resources, compile, process-classes, generate-test-sources, process-test- sources, generate-test-resources, process-test-resources, test-compile, test, prepare-package, package, integration-test, verify, install, deploy.<\/strong><br \/>\n* Commonly used: <strong>validate, compile, test, package, install, deploy, clean, site<\/strong><\/p>\n<span id=\"Maven_Plugins\"><h3>Maven Plugins<\/h3><\/span>\n<p>* Phases are made of plugins which contain goals.<br \/>\n* Maven is a framework of orderly execution of plugin goals.<br \/>\n* See <a href=\"?p=12570\">this post<\/a><\/p>\n<span id=\"Generate_a_List_of_Archetypes\"><h3>Generate a List of Archetypes<\/h3><\/span>\n<p>Archetype list could be long. Here is simple way to get a list of all archetypes:<br \/>\n* Redirect output to a file<\/p>\n<pre lang=\"bash\">\r\nmvn archetype:generate > mvn_archetypes.txt\r\nctr-c to terminate\r\n<\/pre>\n<p>* Browse mvn_archetypes.txt for archetypes<br \/>\n* For example, sample Maven Webapp project archetype:<\/p>\n<pre lang=\"bash\">\r\n174: remote -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.)\r\n<\/pre>\n<span id=\"Copy_a_Jar_File_to_Local_Repository\"><h3>Copy a Jar File to Local Repository<\/h3><\/span>\n<p>* For example, copy Oracle <em>ojdbc6.jar<\/em> file to local repository:<\/p>\n<pre lang=\"bash\">\r\nmvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.2.0 -Dpackaging=jar -Dfile=\"C:\\downloads\\jdbc\\ojdbc6.jar\"\r\n<\/pre>\n<span id=\"Maven_Help\"><h3>Maven Help<\/h3><\/span>\n<pre>\r\n# List help goals\r\nmvn help:help\r\n\r\n# Print plugin info\r\nmvn help:describe -Dplugin=compiler\r\n\r\n# Print plugin info defail\r\nmvn help:describe -Dplugin=compiler -Ddetail\r\n<\/pre>\n<span id=\"Site_Report\"><h3>Site Report<\/h3><\/span>\n<pre>\r\nmvn site\r\n<\/pre>\n<span id=\"Resources\"><h3>Resources<\/h3><\/span>\n<p>* A resource is a file that is used at run time but does not require compilation. For example, <em>log4j.properties<\/em> file.<\/p>\n<span id=\"Project_Dependencies\"><h2>Project Dependencies<\/h2><\/span>\n<p>* Can manage both internal (i.e. your projects) and external dependencies<\/p>\n<span id=\"Project_Scope\"><h3>Project Scope<\/h3><\/span>\n<p>* <em>compile<\/em>:<br \/>\n&#8211; default scope<br \/>\n&#8211; available in <strong>all<\/strong> (compilation, runtime, test) classpaths<br \/>\n&#8211; packaged<br \/>\n* <em>provided<\/em>:<br \/>\n&#8211; available in <strong>compilation<\/strong> classpath <strong>only<\/strong><br \/>\n&#8211; <strong>not<\/strong> packaged<br \/>\n* <em>runtime<\/em>:<br \/>\n&#8211; available in <strong>runtime<\/strong> classpath <strong>only<\/strong><br \/>\n&#8211; not needed for compilation<br \/>\n&#8211; <strong>not<\/strong> packaged<br \/>\n* <em>test<\/em>:<br \/>\n&#8211; available in <strong>test<\/strong> classpath <strong>only<\/strong><br \/>\n&#8211; not needed for either compilation nor runtime<br \/>\n* <em>system<\/em>:<br \/>\n&#8211; like provided but you <strong>must<\/strong> provide <em>systempath<\/em> element<\/p>\n<span id=\"Dependency_Version_Range\"><h3>Dependency Version Range<\/h3><\/span>\n<p>* <em>(,)<\/em> exclusive<br \/>\n* <em>[,]<\/em> inclusive<br \/>\n* Greater or equal to 3.8 but less than 4.0<\/p>\n<pre lang=\"xml\">\r\n<version>[3.8,4.0)<\/version>\r\n<\/pre>\n<p>* No higher than 3.8, lower versions are ok: <\/p>\n<pre lang=\"xml\">\r\n<version>[,3.8]<\/version>\r\n<\/pre>\n<span id=\"dependencyManagement\"><h3>dependencyManagement<\/h3><\/span>\n<p>* Different from <em>dependencies<\/em> element.<br \/>\n* Used in parent project to specify a version number (like an env variable)<br \/>\n* Allows child project to omit specifying version. For example:<br \/>\n&#8211; Parent pom:<\/p>\n<pre lang=\"xml\">\r\n<project>\r\n    <modelVersion>4.0.0<\/modelVersion>\r\n    <groupId>org.sonatype.mavenbook<\/groupId>\r\n    <artifactId>a-parent<\/artifactId>\r\n    <version>1.0.0<\/version>\r\n    ...\r\n    <dependencyManagement>\r\n        <dependencies>\r\n            <dependency>\r\n                <groupId>mysql<\/groupId>\r\n                <artifactId>mysql-connector-java<\/artifactId>\r\n                <version>5.1.2<\/version>\r\n                <scope>runtime<\/scope>\r\n            <\/dependency>\r\n            ...\r\n            <dependencies>\r\n<\/pre>\n<p>&#8211; Child pom:<\/p>\n<pre lang=\"xml\">\r\n<project>\r\n    <modelVersion>4.0.0<\/modelVersion>\r\n    <parent>\r\n        <groupId>org.sonatype.mavenbook<\/groupId>\r\n        <artifactId>a-parent<\/artifactId>\r\n        <version>1.0.0<\/version>\r\n    <\/parent>\r\n    <artifactId>project-a<\/artifactId>\r\n    ...\r\n    <dependencies>\r\n        <dependency>\r\n            <groupId>mysql<\/groupId>\r\n            <artifactId>mysql-connector-java<\/artifactId>\r\n        <\/dependency>\r\n    <\/dependencies>\r\n<\/project>\r\n<\/pre>\n<span id=\"Project_Coordinates\"><h3>Project Coordinates<\/h3><\/span>\n<p>* <em>groupId<\/em>:<br \/>\n&#8211; Similar to Java package<br \/>\n&#8211; Uses dot notation<br \/>\n&#8211; For example: org.apache.maven<br \/>\n* <em>artifactId<\/em>:<br \/>\n&#8211; Similar to Java class<br \/>\n&#8211; Do not use dot notation<br \/>\n* <em>version<\/em><br \/>\n* <em>classifier<\/em>:<br \/>\n&#8211; Less used<br \/>\n&#8211; Used to differentiate different builds (e.g. Java 1.4 build vs Java 6 build) based on same codes<\/p>\n<span id=\"Project_Inheritance\"><h3>Project Inheritance<\/h3><\/span>\n<p>* Child project inherits <strong>all<\/strong> properties from parent project:<br \/>\n&#8211; identifiers (at least one of groupId or artifactId must be overridden.)<br \/>\n&#8211; dependencies<br \/>\n&#8211; developers and contributors<br \/>\n&#8211; plugin lists<br \/>\n&#8211; reports lists<br \/>\n&#8211; plugin executions (executions with matching ids are merged)<br \/>\n&#8211; plugin configuration<br \/>\n* Child pom can override parent pom<br \/>\n* To view an effective, i.e. merged, pom:<\/p>\n<pre lang=\"bash\">\r\nmvn help:effective-pom\r\n<\/pre>\n<span id=\"Group_Dependencies\"><h3>Group Dependencies<\/h3><\/span>\n<p>* Group common dependencies into a <strong>shared<\/strong> project<br \/>\n* For example, put shared dependencies, e.g. hiberntae, spring, and mysql, in a single POM project:<\/p>\n<pre lang=\"xml\">\r\n<project>\r\n    <groupId>org.sonatype.mavenbook<\/groupId>\r\n    <artifactId>persistence-deps<\/artifactId>\r\n    <version>1.0<\/version>\r\n    <packaging>pom<\/packaging>\r\n    <dependencies>\r\n        <dependency>\r\n            <groupId>org.hibernate<\/groupId>\r\n            <artifactId>hibernate<\/artifactId>\r\n            <version>${hibernateVersion}<\/version>\r\n        <\/dependency>\r\n        <dependency>\r\n            <groupId>org.hibernate<\/groupId>\r\n            <artifactId>hibernate-annotations<\/artifactId>\r\n            <version>${hibernateAnnotationsVersion}<\/version>\r\n        <\/dependency>\r\n        <dependency>\r\n            <groupId>org.springframework<\/groupId>\r\n            <artifactId>spring-hibernate3<\/artifactId>\r\n            <version>${springVersion}<\/version>\r\n        <\/dependency>\r\n        <dependency>\r\n            <groupId>mysql<\/groupId>\r\n            <artifactId>mysql-connector-java<\/artifactId>\r\n            <version>${mysqlVersion}<\/version>\r\n        <\/dependency>\r\n    <\/dependencies>\r\n    <properties>\r\n        <mysqlVersion>(5.1,)<\/mysqlVersion>\r\n        <springVersion>(2.0.6,)<\/springVersion>\r\n        <hibernateVersion>3.2.5.ga<\/hibernateVersion>\r\n        <hibernateAnnotationsVersion>3.3.0.ga<\/hibernateAnnotationsVersion>\r\n    <\/properties>\r\n<\/project>\r\n<\/pre>\n<p>* Now declare a shared project dependency in project POM:<\/p>\n<pre lang=\"xml\">\r\n<project>\r\n    <description>This is a project requiring JDBC<\/description>\r\n    ...\r\n    <dependencies>\r\n        ...\r\n        <dependency>\r\n            <groupId>org.sonatype.mavenbook<\/groupId>\r\n            <artifactId>persistence-deps<\/artifactId>\r\n            <version>1.0<\/version>\r\n            <type>pom<\/type>\r\n        <\/dependency>\r\n    <\/dependencies>\r\n<\/project>\r\n<\/pre>\n<span id=\"Inheritance_or_Multi-Module_Composition\"><h3>Inheritance or Multi-Module Composition<\/h3><\/span>\n<p>* In inheritance, child project inherits <strong>all<\/strong> values from parent.<br \/>\n* In multi-moduel, projects are simply grouped together. No parent-child relationship implied.<br \/>\n* See <a href=\"?p=6115\">this post<\/a> on how to setup multi-module projects.<\/p>\n<span id=\"The_Build_Lifecycle\"><h2>The Build Lifecycle<\/h2><\/span>\n<p>* Consists of a sequence of named phases to produce a set of goals<br \/>\n* Default goals<br \/>\n&#8211; clean<br \/>\n&#8211; default (aka build)<br \/>\n&#8211; site: produce a web site files<\/p>\n<span id=\"Clean_Lifecycle\"><h3>Clean Lifecycle<\/h3><\/span>\n<p>* pre-clean<br \/>\n* clean: deletes build directory<br \/>\n* post-clean<\/p>\n<span id=\"Default_Lifecycle\"><h3>Default Lifecycle<\/h3><\/span>\n<p>* validate: Validate the project is correct and all necessary information is available to complete a build<\/p>\n<span id=\"Sources\"><h4>Sources<\/h4><\/span>\n<p>* generate-sources: Generate any source code for inclusion in compilation<br \/>\n* process-sources: Process the source code, for example to filter any values<\/p>\n<span id=\"Resources_1\"><h4>Resources<\/h4><\/span>\n<p>* generate-resources: Generate resources for inclusion in the package<br \/>\n* process-resources: Copy and process the resources into the destination directory, ready for packaging <\/p>\n<p>* compile: Compile the source code of the project<br \/>\n* process-classes: Post-process the generated files from compilation, for example to do bytecode enhancement on Java classes<\/p>\n<span id=\"Test\"><h4>Test<\/h4><\/span>\n<p>* generate-test-sources: Generate any test source code for inclusion in compilation<br \/>\n* process-test-sources: Process the test source code, for example to filter any values<br \/>\n* generate-test-resources: Create resources for testing<br \/>\n* process-test-resources: Copy and process the resources into the test destination directory<br \/>\n* test-compile: Compile the test source code into the test destination directory<br \/>\n* test: Run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed<\/p>\n<span id=\"Package\"><h4>Package<\/h4><\/span>\n<p>* prepare-package: Perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package (coming in Maven 2.1+)<br \/>\n* package: Take the compiled code and package it in its distributable format, such as a JAR, WAR, or EAR<\/p>\n<span id=\"Integration_Test\"><h4>Integration Test<\/h4><\/span>\n<p>* pre-integration-test: Perform actions required before integration tests are executed. This may involve things such as setting up the required environment<br \/>\n* integration-test: Process and deploy the package if necessary into an environment where integration tests can be run<br \/>\n* post-integration-test: Perform actions required after integration tests have been executed. This may include cleaning up the environment<br \/>\n* verify: Run any checks to verify the package is valid and meets quality criteria<\/p>\n<span id=\"Install_and_Deploy\"><h4>Install and Deploy<\/h4><\/span>\n<p>* install: Install the package into the local repository, for use as a dependency in other projects locally<br \/>\n* deploy: Copies the final package to the remote repository for sharing with other developers and projects (usually only relevant during a formal release)<\/p>\n<span id=\"Site_Lifecycle\"><h3>Site Lifecycle<\/h3><\/span>\n<p>* pre-site<br \/>\n* site<br \/>\n* post-site<br \/>\n* site-deploy<\/p>\n<span id=\"Packaging_Specific_Lifecycles\"><h3>Packaging Specific Lifecycles<\/h3><\/span>\n<p>* pom: simplest packaging type<br \/>\n* jar: default packaging type<br \/>\n* maven-plugin: generate a descriptor file and perform some modifications to the repository data in addition to <em>jar<\/em>:<br \/>\n&#8211; plugin:descriptor,<br \/>\n&#8211; plugin:addPluginArtifactMetadata<br \/>\n&#8211; plugin:updateRegistry<br \/>\n* ejb<br \/>\n* war<br \/>\n* ear<br \/>\n* Others<\/p>\n<span id=\"Common_Lifecycle_Goals\"><h2>Common Lifecycle Goals<\/h2><\/span>\n<span id=\"Process_Resources\"><h3>Process Resources<\/h3><\/span>\n<p>* Process resources in the <em>${basedir}\/src\/main\/resources<\/em> directory<br \/>\n* Perform token replacement<br \/>\n* Copy resource to output directory as defined by the <em>${project.build.outputDirectory}<\/em>, which defaults to <em>${basedir}\/target\/classes<\/em> directory<\/p>\n<span id=\"Resource_Filtering_Token_Replacement\"><h4>Resource Filtering (Token Replacement)<\/h4><\/span>\n<p>* File to be filtered: <em>src\/main\/resources\/service.xml<\/em><\/p>\n<pre lang=\"xml\">\r\n<service>\r\n    <!-- This URL was set by project version ${project.version} -->\r\n    <url>${jdbc.url}<\/url>\r\n    <user>${jdbc.username}<\/user>\r\n    <password>${jdbc.password}<\/password>\r\n<\/service>\r\n<\/pre>\n<p>* Property file: <em>src\/main\/filters\/default.properties<\/em><\/p>\n<pre lang=\"bash\">\r\njdbc.url=jdbc:oracle:thin:@\/\/myhost:1521\/orcl\r\njdbc.username=scott\r\njdbc.password=tiger\r\n<\/pre>\n<p>* Specify filters in <em>pom.xml<\/em>:<\/p>\n<pre lang=\"xml\">\r\n<build>\r\n    <filters>\r\n        <filter>src\/main\/filters\/default.properties<\/filter>\r\n    <\/filters>\r\n    <resources>\r\n        <resource>\r\n            <directory>src\/main\/resources<\/directory>\r\n            <filtering>true<\/filtering>\r\n        <\/resource>\r\n    <\/resources>\r\n<\/build>\r\n<\/pre>\n<p>* Run: <em><strong>mvn process-resources<\/strong><\/em> command<br \/>\n* Check service.xml in <em>target\\classes\\META-INF<\/em> directory: <\/p>\n<pre lang=\"xml\">\r\n<service>\r\n    <!-- This URL was set by project version 1.0-SNAPSHOT -->\r\n    <url>jdbc:oracle:thin:@\/\/myhost:1521\/orcl<\/url>\r\n    <user>scott<\/user>\r\n    <password>tiger<\/password>\r\n<\/service>\r\n<\/pre>\n<span id=\"Multiple_Resource_Directories\"><h4>Multiple Resource Directories<\/h4><\/span>\n<p>* Create a separate directory to contain command files:<br \/>\n<em>src\/main\/command<\/em><br \/>\n* Create a command file in that directory:<\/p>\n<pre lang=\"bash\">\r\n@echo off\r\njava -jar ${project.build.finalName}.jar %*\r\n<\/pre>\n<p>* Define a new resource:<\/p>\n<pre lang=\"xml\">\r\n        <resource>\r\n            <filtering>true<\/filtering>\r\n            <directory>${basedir}\/src\/main\/command<\/directory>\r\n            <includes>\r\n                <include>run.bat<\/include>\r\n                <include>run.sh<\/include>\r\n            <\/includes>\r\n            <targetPath>${basedir}<\/targetPath>\r\n        <\/resource>\r\n<\/pre>\n<p>* Run: <em><strong>mvn process-resources<\/strong><\/em> command<br \/>\n* Check run.bat in the project root directory:<\/p>\n<pre lang=\"bash\">\r\n@echo off\r\njava -jar guide-ide-eclipse-1.0-SNAPSHOT.jar %*\r\n<\/pre>\n<span id=\"Compile\"><h3>Compile<\/h3><\/span>\n<p>* Compile everything from <em>src\/main\/java<\/em> to <em>target\/classes<\/em><br \/>\n* Defaults to compliance with Java 1.3 source code and Java 1.1 JVM.<br \/>\n* Use specific source and target Java versions:<\/p>\n<pre lang=\"xml\">\r\n<project>\r\n    ...\r\n    <build>\r\n        ...\r\n        <plugins>\r\n            <plugin>\r\n                <artifactId>maven-compiler-plugin<\/artifactId>\r\n                <configuration>\r\n                    <source>1.5<\/source>\r\n                    <target>1.5<\/target>\r\n                <\/configuration>\r\n            <\/plugin>\r\n        <\/plugins>\r\n        ...\r\n    <\/build>\r\n    ...\r\n<\/project>\r\n<\/pre>\n<p>* Overriding default source diretory<\/p>\n<pre lang=\"xml\">\r\n<build>\r\n    ...\r\n    <sourceDirectory>src\/java<\/sourceDirectory>\r\n    <outputDirectory>classes<\/outputDirectory>\r\n    ...\r\n<\/build>\r\n<\/pre>\n<span id=\"Sample_Webapp_Project\"><h2>Sample Webapp Project<\/h2><\/span>\n<p>* <a href=\"?p=5993\">Sample Maven webapp project<\/a><\/p>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"http:\/\/maven.apache.org\/guides\/getting-started\/\">Maven Getting Started Guide<\/a><br \/>\n* <a href=\"http:\/\/www.sonatype.com\/books\/mvnref-book\/reference\/public-book.html\">Maven: The Complete Reference<\/a><br \/>\n* Apache Maven 2 Effective Implementation By: Brett Porter; Maria Odea Ching<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install * Download Maven, e.g. apache-maven-2.2.1-bin.zip, from Maven download site: http:\/\/maven.apache.org\/download.html * Unzip content into a local directory, e.g. C:\\prog * Create an environment variable called MAVEN_HOME and point it to where maven was unzipped, e.g. C:\\prog\\apache-maven-2.2.1 * Add %MAVEN_HOME%\\bin &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=4348\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[128],"tags":[],"class_list":["post-4348","post","type-post","status-publish","format-standard","hentry","category-maven"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-188","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4348"}],"version-history":[{"count":5,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4348\/revisions"}],"predecessor-version":[{"id":12575,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4348\/revisions\/12575"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}