锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
mvn archetype:create灝卞彲浠?/span>
涓嶈繃錛屽垱寤虹殑鍚屾椂闇瑕乤rchetypeArtifactId榪欎釜鍙傛暟鏉ヨ瘑鍒紝涓嶈繃涓嶅お娓呮鏈変粈涔堢被鍨嬶紝鍙煡閬撻粯璁や笉濉槸maven-archetype-quickstart 錛寃eb鏄痬aven-archetype-webapp
鍙戠幇鏈夋洿綆鍗曠殑鏂規(guī)硶錛屽彧瑕佽緭鍏vn archetype:generate
灝變細(xì)灝嗘墍鏈夊彲鐢ㄧ殑綾誨瀷鏄劇ず錛屽茍涓旇浣犺嚜宸遍夛紝杈撳嚭濡備笅錛?/span>
1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)
2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)
3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2)
4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4)
5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire)
6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF)
7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC)
8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2)
9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4)
10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application)
11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade)
12: internal -> maven-archetype-mojo (A Maven Java plugin development project)
13: internal -> maven-archetype-portlet (A simple portlet application)
14: internal -> maven-archetype-profiles ()
15: internal -> maven-archetype-quickstart ()
16: internal -> maven-archetype-site-simple (A simple site generation project)
17: internal -> maven-archetype-site (A more complex site project)
18: internal -> maven-archetype-webapp (A simple Java web application)
19: internal -> struts2-archetype-starter (A starter Struts 2 application with Sitemesh, DWR, and Spring)
20: internal -> struts2-archetype-blank (A minimal Struts 2 application)
21: internal -> struts2-archetype-portlet (A minimal Struts 2 application that can be deployed as a portlet)
22: internal -> struts2-archetype-dbportlet (A starter Struts 2 portlet that demonstrates a simple CRUD interface with db backing)
23: internal -> struts2-archetype-plugin (A Struts 2 plugin)
24: internal -> shale-archetype-blank (A blank Shale web application with JSF)
25: internal -> maven-adf-archetype (Archetype to ease the burden of creating a new application based with ADF)
26: internal -> data-app (A new Databinder application with sources and resources.)
27: internal -> jini-service-archetype (Archetype for Jini service project creation)
28: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)
29: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)
30: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)
31: internal -> jpa-maven-archetype (JPA application)
32: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)
33: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)
34: internal -> maven-archetype-har (Hibernate Archive)
35: internal -> maven-archetype-sar (JBoss Service Archive)
36: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)
<mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> ======================================================== OSChina Maven 搴撲嬌鐢ㄥ府鍔? ==================鍏朵粬maven浠撳簱闀滃儚========================== <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> <mirror> <id>net-cn</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://maven.net.cn/content/groups/public/</url> </mirror> <mirror> <id>ui</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://uk.maven.org/maven2/</url> </mirror> <mirror> <id>ibiblio</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url> </mirror> <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> </mirror>
<mirror> <id>JBossJBPM</id>
銆銆銆銆<mirrorOf>central</mirrorOf>
銆銆銆銆<name>JBossJBPM Repository</name>
銆銆銆銆<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</mirror>
Maven浼?xì)娌跨潃鐖跺瓙灞傛鍚戜笂璧幫紝鐩村埌鎵懼埌涓涓嫢鏈塪ependencyManagement鍏冪礌鐨勯」鐩紝鐒跺悗瀹冨氨浼?xì)鋴社敤鍦q欎釜dependencyManagement鍏冪礌涓寚瀹氱殑鐗堟湰鍙楓?/p>
鐒跺悗錛屽湪瀛愰」鐩腑錛屼綘鍙互浣跨敤濡備笅鐨勪緷璧朮ML娣誨姞涓涓MySQL Java Connector鐨勪緷璧栵細(xì)
濡傛灉mysql-connector-java鍦ㄩ《灞傜埗欏圭洰涓浣滀負(fù)涓涓緷璧栧垪鍑猴紝榪欎釜灞傛涓殑鎵鏈夐」鐩兘灝嗗紩鐢ㄨ渚濊禆銆備嬌鐢╠ependencyManagement鑳借浣犵粺涓騫墮泦涓寲渚濊禆鐗堟湰鐨勭鐞嗭紝鑰屼笉鐢ㄦ坊鍔犻偅浜涗細(xì)琚墍鏈夊瓙欏圭洰緇ф壙鐨勪緷璧栥?/p>
瑙e喅榪欎釜闂鐨勬柟娉曞氨鏄嬌鐢?lt;scope>鏍囩錛屽涓?/p>
榪欓噷鐨勬剰鎬濇槸璇達(dá)紝緙栬瘧鐨勬椂鍊欑敤鍒皊ervlet-api鍜宩sp-api錛屼絾鍦ㄦ墦鍖呯殑鏃跺欎笉鐢ㄨ繖涓や釜渚濊禆銆?/p>
鍦╩aven鐨勫畼鏂逛腑鏄繖鏍鋒弿榪扮殑
Dependency Scope
Dependency scope is used to limit the transitivity of a depedency, and also to affect the classpath used for various build tasks.
There are 6 scopes available:
compile
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
provided
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
runtime
This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
test
This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
system
This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
import (only available in Maven 2.0.9 or later)
This scope is only used on a dependency of type pom in the <dependencyManagement> section. It indicates that the specified POM should be replaced with the dependencies in that POM's <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.
濡傛灉浣犺繖鏍峰仛浜?jiǎn)锛屼絾鋴社敤eclipse+tomcat鍋氭祴璇曠殑鏃跺欏彂鐜皊ervlet-api榪樻槸琚墦鍖呭埌l(fā)ib涓嬮潰浜?jiǎn)锛屼綘瑕佹妸maven鎻掍歡涓殑WTP涔熷畨瑁呬竴涓嬶紝闂搴旇灝辮В鍐充簡(jiǎn)銆?br />
private static final char PATH_SEPARATOR = '/';
private static final char GROUP_SEPARATOR = '.';
private static final char ARTIFACT_SEPARATOR = '-';
public String pathOf( Artifact artifact )
{
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
StringBuilder path = new StringBuilder( 128 );
path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR );
path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR );
path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
if ( artifact.hasClassifier() )
{
path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() );
}
if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
{
path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() );
}
return path.toString();
}
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
}
??
璇athOf()鏂規(guī)硶鐨勭洰鐨勬槸鏍規(guī)嵁鏋勪歡淇℃伅鐢熸垚鍏跺湪浠撳簱涓殑璺緞銆傚湪闃呰鏈浠g爜涔嬪墠錛岃鑰呭彲浠ュ厛鍥為【涓涓嬩笂涓绔燤aven鍧愭爣鐨勭浉鍏沖唴瀹廣傝繖閲岋紝鎴戜滑鏍規(guī)嵁涓涓疄闄呯殑渚嬪瓙鏉ュ垎鏋愯礬寰勭殑鐢熸垚錛岃冭檻榪欐牱涓涓瀯浠訛細(xì)groupId=org.testng銆乤rtifactId=testng銆乿ersion=5.8銆乧lassifier=jdk15銆乸ackaging=jar錛屽叾瀵瑰簲鐨勮礬寰勬寜濡備笅姝ラ鐢熸垚錛?/p>
棣栧厛鍩轟簬鏋勪歡鐨刧roupId鍑嗗璺緞錛宖ormatAsDirectory()灝唃roupId涓殑鍙ョ偣鍒嗛殧絎﹁漿鎹㈡垚璺緞鍒嗛殧絎︼紝璇ヤ緥涓紝groupId org.testng灝變細(xì)琚漿鎹㈡垚org/testng錛屼箣鍚庡啀鍔犱竴涓礬寰勫垎闅旂鏂滄潬錛岄偅涔坥rg.testng灝辨垚涓轟簡(jiǎn)org/testng/銆?
鍩轟簬鏋勪歡鐨刟rtifactId鍑嗗璺緞錛屼篃灝辨槸鍦ㄥ墠闈㈢殑鍩虹涓婂姞涓奱rtifactId浠ュ強(qiáng)涓涓礬寰勫垎闅旂錛岃渚嬩腑鐨刟rtifactId涓簍estng錛岄偅涔堝湪榪欎竴姝ヨ繃鍚庤礬寰勫氨鎴愪負(fù)浜?jiǎn)org/testng/testng/銆?
鎺ョ潃浣跨敤鐗堟湰淇℃伅錛屽湪鍓嶉潰鐨勫熀紜涓婂姞涓妚ersion鍜岃礬寰勫垎闅旂錛岃渚嬩腑鐗堟湰鏄?.8錛岄偅涔堣礬寰勫氨鎴愪負(fù)浜?jiǎn)org/testng/tesgng/5.8/銆?
榪欎竴姝ュ啀渚濇鍔犱笂artifactId錛屾瀯浠跺垎闅旂榪炲瓧鍙鳳紝浠ュ強(qiáng)version錛屼簬鏄瀯寤虹殑璺緞灝卞彉鎴愪簡(jiǎn)org/testng/testng/5.8/testng-5.8銆傝鑰呭彲鑳戒細(xì)娉ㄦ剰鍒拌繖閲屼嬌鐢ㄤ簡(jiǎn)artifactId.getVersion()錛岃屼笂涓姝ョ敤鐨勬槸artifactId.getBaseVersion()錛寁ersion鍜宐aseVersion鐨勫尯鍒湪鏈珷璁ㄨSNAPSHOT鐨勬椂鍊欎細(xì)鍏蜂綋闃愯堪銆?
绱ф帴鐫濡傛灉鏋勪歡鏈塩lassifier錛屽氨鍔犱笂鏋勪歡鍒嗛殧絎﹀拰classifier錛岃渚嬩腑鏋勪歡鐨刢lassifier鏄痡dk15錛岄偅涔堣礬寰勫氨鍙樻垚org/testng/testng/5.8/testng-5.8-jdk5銆?
鏈鍚庣媯(gè)鏌ユ瀯浠剁殑extension錛岃嫢extension瀛樺湪錛屽垯鍔犱笂鍙ョ偣鍒嗛殧絎﹀拰extension錛屼粠浠g爜涓彲浠ョ湅鍒幫紝extension鏄粠artifactHandler鑰岄潪artifact鑾峰彇錛宎rtifactHandler鏄敱欏圭洰鐨刾ackaging鍐沖畾鐨勶紝鍥犳鍙互璇達(dá)紝packaging鍐沖畾浜?jiǎn)鏋勪欢鐨勬墿灞曞悕锛岃渚嬬殑packaging鏄殑jar錛屽洜姝ゆ渶緇堢殑璺緞涓簅rg/testng/testng/5.8/testng-5.8-jdk5.jar銆?
鍒拌繖閲岀瑪鑰咃紙鍖呮嫭璇昏呬綘錛夐兘搴旇鎰熻阿Maven寮婧愮ぞ鍖猴紝姝f槸鐢變簬Maven鐨勬墍鏈夋簮浠g爜閮芥槸寮鏀劇殑錛屾垜浠墠鑳戒粩緇嗗緱娣卞叆鍒板叾鍐呴儴宸ヤ綔鐨勬墍鏈夌粏鑺傘?
鐢變簬Maven浠撳簱鏄熀浜庣畝鍗曟枃浠剁郴緇熷瓨鍌ㄧ殑錛岀幇鍦ㄦ垜浠張鐞嗚В浜?jiǎn)鍏跺瓨鍌ㄦ柟寮忓Q屽洜姝ゅ綋閬囧埌涓浜涗笌浠撳簱鐩稿叧鐨勯棶棰樻椂錛屽彲浠ュ緢鏂逛究鐨勬煡鎵劇浉鍏蟲枃浠訛紝鏂逛究瀹氫綅闂銆備緥濡傚綋Maven鏃犳硶鑾峰緱欏圭洰澹版槑鐨勪緷璧栨椂錛屽彲浠ョ畝鍗曡渚濊禆瀵瑰簲鐨勬枃浠跺湪浠撳簱涓槸鍚﹀瓨鍦紝濡傛灉涓嶅瓨鍦紝鏄惁鏈夊叾瀹冪増鏈彲鐢紝絳夌瓑銆?