Ò». Ê×ÏÈ£¬MavenÊÇʲô?ÍøÉÏËѵ½µÄͨË×µãµÄ˵·¨ÊÇÕâÑùµÄ£º
MavenÊÇÒ»¸öÏîÄ¿¹¹½¨ºÍ¹ÜÀíµÄ¹¤¾ß£¬ÌṩÁË°ïÖú¹ÜÀí ¹¹½¨¡¢Îĵµ¡¢±¨¸æ¡¢ÒÀÀµ¡¢scms¡¢·¢²¼¡¢·Ö·¢µÄ·½·¨¡£¿ÉÒÔ·½±ãµÄ±àÒë´úÂë¡¢½øÐÐÒÀÀµ¹ÜÀí¡¢¹ÜÀí¶þ½øÖÆ¿âµÈµÈ¡£
mavenµÄºÃ´¦ÔÚÓÚ¿ÉÒÔ½«ÏîÄ¿¹ý³Ì¹æ·¶»¯¡¢×Ô¶¯»¯¡¢¸ßЧ»¯ÒÔ¼°Ç¿´óµÄ¿ÉÀ©Õ¹ÐÔ
ÀûÓÃmaven×ÔÉí¼°Æä²å¼þ»¹¿ÉÒÔ»ñµÃ´úÂë¼ì²é±¨¸æ¡¢µ¥Ôª²âÊÔ¸²¸ÇÂÊ¡¢ÊµÏÖ³ÖÐø¼¯³ÉµÈµÈ¡£
ÒÔÎÒµÄÀí½â£¬Ä¿Ç°ÔÚÏîÄ¿ÖУ¬´ó¶àÊý¶¼ÊÇÓÃMaven½øÐÐJar°üµÄ°æ±¾¹ÜÀí¡£
MavenµÄ¾ÛºÏ¹¤³Ì¹ÜÀíÓÈÆä·½±ã£¬µ±Ò»¸ö´óµÄÏîÄ¿°üº¬ºÜ¶àÄ£¿éµÄʱºò£¬Ã¿¸öÈË¿ª·¢Íê×Ô¼ºµÄÄ£¿é£¬¿ÉÒÔͨ¹ýMaven¾ÛºÏ¹¤³Ì½øÐа汾¹ÜÀí¡£
¶þ. Óõ½µÄ¹¤¾ß£º
1.ÏÈÈ¥¹ÙÍøÏÂÔØapache-maven-3.1.1£¨±ØÐ룬Äã¿ÉÒÔ°ÑMavenÀí½âΪһ¸öJar°üµÄ²Ö¿â¡££©
2.repository£¨Õâ¸öÊDZ¾µØJar°ü²Ö¿â£¬Ã»ÓеĻ°£¬Ã¿´ÎÏîÄ¿ÖÐÓõ½Jar°üµÄʱºò¶¼»áÈ¥Maven·þÎñÆ÷ÉÏÏÂÔØ£»×îºÃÕÒһϱðÈ˵IJֿâÄùýÀ´£¬ÕâÑùµÄ»°£¬Ã¿´ÎÓõ½Jar°ü»áÏÈ´Ó±¾µØ²Ö¿âÕÒ£¬Ã»ÓеÄÔÙ´ÓMaven·þÎñÆ÷ÉÏ×Ô¶¯ÏÂÔص½±¾µØ²Ö¿â£¬È»ºóÔÚ¸´ÖƵ½ÏîÄ¿ÖС£repositoryÔÚMavenµÄsetting.xmlÖÐÅäÖÃһϼ´¿É£¬Õâ¸öºóÃæ˵£©
3.nexus-2.14.2-01£¨nexusÊÇ˽·þ£¬Ï൱ÓÚÊǽ¨ÔÚ¹«Ë¾·þÎñÆ÷ÉϵÄMaven¡£ÒòΪºÜ¶à¹«Ë¾ÏÞÖÆÍâÍøÁ¬½Ó£¬Èç¹ûûÓÐ˽·þ£¬Äã¸ù±¾²»ÄÜ´ÓMaven¹ÙÍøÏÂÔØJar°ü£¬ËùÒÔ¿ÉÒÔÔÚÄÜÁ¬½ÓÍâÍøµÄ»úÆ÷ÉϽ¨Á¢nexus£¬ÆäËû¾ÖÓòÍøµÄ»úÆ÷Ö±½Ó´ÓnexusÏÂÔØJar°ü¼´¿É£©
Èý. ´î½¨Maven
½«apache-maven-3.1.1ºÍrepository·ÅÔÚD:\mavenÖС£
MavenµÄºËÐÄÅäÖÃÎļþÊÇsettings.xml£¬ÏÂÃæÊÇÎÒ¸ÄÍêµÄÅäÖÃÎļþ¡£
<?xml version="1.0" encoding="UTF-8"?>
<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">
<localRepository>D:\maven\repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-repos</id>
<mirrorOf>*</mirrorOf>
<name>Team Nexus Repository</name>
<url>http://192.168.8.79:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jdk-1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
</settings>
×¢ÒâÐ޸ĵĵط½ÈçÏ£º
1.ÅäÖñ¾µØ²Ö¿â£¬Ö¸Ïòrepository½âѹºóλÖãº
<localRepository>D:\Program Files\repository\repository</localRepository>
2.Mirrors±êÇ©ÖÐÌí¼Ó˽·þÅäÖã¬Ö¸Ïò¹«Ë¾·þÎñÆ÷ÉϵÄnexus˽·þ
<mirror>
<id>nexus-repos</id>
<mirrorOf>*</mirrorOf>
<name>Team Nexus Repository</name>
<url>http://192.168.3.100:8099/nexus/content/groups/public/</url>
</mirror>
3.´ò¿ªmyEclipse -> windows -> perferencesËÑË÷mavenÈçÏÂͼ
4.Installations -> add ÕÒµ½apache-maven-3.1.1½âѹºóµÄĿ¼¡ªÈ·¶¨
5.User settings -> browseÕÒµ½2ÖÐÐ޸ĵÄsettings.xmlÎÄ -> update settings -> reindex -> apply
6.windows -> show View -> otherÕÒµ½Maven repositories¿´µ½ÏÂͼ֤Ã÷ÅäÖÃÍê³É
ËÄ. ´´½¨MavenÏîÄ¿
1.ÔÚMyEclipseÖд´½¨Maven Project
2.½«MavenÏîĿתΪWebÏîÄ¿
ÏîÄ¿ÓÒ¼üµã»÷Properties
ÏîÄ¿½á¹¹¾Í±ä³ÉÁËÕâÑù£¬±ê×¼µÄwebÏîÄ¿
3.MavenÏîÄ¿µÄºËÐÄ£ºpom.xml
pomÊÇÖ¸project object Model¡£
pomÊÇÒ»¸öxml£¬ÊÇmaven¹¤×÷µÄ»ù´¡£¬ÔÚÖ´ÐгÌÐòµÄʱºò£¬maven»áÈ¥ÏîÄ¿¸ùĿ¼Ï¶ÁÈ¡pom.xml»ñµÃÐèÒªµÄÅäÖÃÐÅÏ¢¡£
pomÎļþÖаüº¬ÁËÏîÄ¿µÄÐÅÏ¢ºÍmaven buildÏîÄ¿ËùÐèµÄÅäÖÃÐÅÏ¢£¬Í¨³£ÓÐÏîÄ¿ÐÅÏ¢(Èç°æ±¾¡¢³ÉÔ±)¡¢ÏîÄ¿µÄÒÀÀµ¡¢²å¼þºÍgoal¡¢buildÑ¡ÏîµÈµÈ¡£
½ÓÏÂÀ´Äã¾Í¿ÉÒÔ±àÒëÁË£¬pom.xmlÉÏÓÒ¼üRun As -> Maven install
´ò¿ªtargetĿ¼£º
ºìÉ«µÄÊÇÏîÄ¿´ò³ÉµÄwar°ü£»À¶É«µÄÊÇÄãÔÚpom.xmlÖÐдµÄÏëÒªµ¼ÈëµÄjar°ü
maven-web-0.0.1-SNAPSHOTºÍwar°üµÄÄÚÈÝÊÇÒ»ÑùµÄ£¬¿ÉÒÔ°ÑËûÃǷŵ½TomcatÏÂÃæÔËÐУº
µØÖ·£ºhttp://localhost:8079/maven-web-0.0.1-SNAPSHOT