تقدم هذه المقالة طريقة استخدام Maven لإنشاء حزم جرة قابلة للتنفيذ. تتم مشاركتها معك. التفاصيل كما يلي:
من XSI من POM ، يمكنك فتح المخطط الذي يصف POM:
يمكنك رؤية هيكل المشروع في POM:
لا تحتوي الجرة التي تم إنشاؤها بواسطة تثبيت MVN الافتراضي على إدخال الفئة الرئيسية ، ويجب تعيين الفئة الرئيسية في Maven-Compile-Plugin.
<project xmlns = "http://maven.apache.org/pom/4.0.0" http://maven.apache.org/xsd/maven-4.0.0.xsd "> <Dodeversion> 4.0.0 </modelversion> <roupiD> com.cetc.di </groupid> </packaging> hellocetc </ursifactid> <ame> hellocetc </same> <Url> http://maven.apache.org </url> <properties> <project.build.sourceencoding> utf-8 </project.build.sourceending> </properties> <edependency> <sperize> 3.8.1 </splex> <scope> اختبار </scope> </sependency> </repreadencies> <build> <cultinmanagement> <plugins> <sucplin> <roupiD> org.apache.maven.plugins </rouctid> <//////stifted> <Archive> <Mansest> <Mainclass> com.cetc.di.hellocetc.app </mainclass> <AddClassPath> true </addclasspath> </sultiinmanagement> </build> </project>
تنفيذ تثبيت MVN:
في الدليل المستهدف ، وجد أنه تم إنشاء حزمة جرة:
باستخدام Java Decompiler ، يمكنك أن ترى أنه تمت إضافة Mainclass إلى البيان:
استخدم مساعدة MVN: فعالة لترى الهيكل الكامل لـ pom.xml (بما في ذلك الخصائص الموروثة):
[معلومات] المسح للمشاريع ... [معلومات] [معلومات] ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- المطبقة: <!- =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== =============================================================== ======================================================================================================================== - xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" <Domodversion> 4.0.0 </dodyversion> <rougiD> com.cetc.di </rougeid> <StifactId> hellocetc </shintifactid> <splection> 0.0.1-snapshot </soph> <same> hellocetc </same> <Url> http://maven.apache.org </url> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> </sependencies> <reperationies> <preemid> <roupiD> junit </rougiD> </attifactid> Junit </stifactid> <Spository> <snapshots> <tenupper> false </texuped> </sflishots> <id> Central </id> <name> المستودع المركزي </name> <Url> https://repo.maven.apache.org/maven2 </url> </ropository> <reclostInrepository> <reedease> <uptudePolicy> never </updatePolicy> </reedease> <snapshots> <تمكين> خطأ </enupper </sultiinrepository> <build> <ustredirectory> d:/user/a/workpaces/myeclipse 2015/hellocetc/src/main/java </sourcedirectory> <scriptsourcedirectory> d:/userpts/a/workspaces/myeclipse 2015/hellocetc/src/scripts. <TestsSourcedirectory> d:/user/a/workpaces/myeclipse 2015/hellocetc/src/test/java </testsourcedirectory> <outputdirectory> d:/user/a/workpaces/myeclipse 2015/hellocetc/target/classes </ <TestOutputDirectory> d:/user/a/workpaces/myeclipse 2015/hellocetc/target/test riplasses </testOutputDirectory> <sourgances> <sropergency> <cironsory> d:/users/a/workspaces/myeclipse 2015/hellocetc/src/main/pirans <Criptory> d:/user/a/workpaces/myeclipse 2015/hellocetc/src/test/resources </directory> </testresources> </testresources> <cirlive> d:/users/a/workpshes/myeclipse 2015/hellocetc/target </directory> <UnctionManagement> <evelding> <StifactId> maven-antrun-plugin </artifactId> <الإصدار> 1.3 </version> </suncloy> <clupin> <StifactId> maven-dependency-plugin </shintifactid> <soph> 2.8 </splection> </plugin> <plugin> <sntifactid> maven-release-plugin </shifactid> <splectid> 2.3.2 </splice> </plugin> plugin> <iscturation> <ource> 1.8 </ource> <target> 1.8 </target> <archive> <mantest> <MainClass> com.cetc.di.hellocetc.app </mainclass> <AddClassPath> true </addclasspath> <slasspathprefix> lib/</classpathprefix> </sugionins> </plugins> </sugioninmanagement> <uccedins> <StifactId> maven-clean-plugin </stifactid> <الإصدار> 2.5 </version> <evelopmions> <StifactId> maven-resources-plugin </shintifactid> <الإصدار> 2.6 </version> <evelopmentions> <evelop> <id> testResources الافتراضي </id> <phase> معرفات المعرف </exect> <sivent> <phare> <irod> TestResources </tord> </execution> <evengution> <id> الموارد الافتراضية </id> <phase> موارد العملية </phase> <irod> <nov> الموارد </الهدف> </execution> </sultiin> <sucplin> <vide> jar </siro> </forts> <soction> <source> 1.8 </ource> <irodge> 1.8 </asplic> <Archive> <Mansest> <mainclass> com.cetc.di.hellocetc.app </mainclass> <adclasspath> true </eddclasspath> <ClassEdirectory/> </configuration> </evelop> </executions> <configuration> <ource> 1.8 </ource> <target> 1.8 </target> </rarchive> <classeSdirectory/> </configuration> </sucplin> <cludin> <suntifactid> maven-compiler-plugin </stifactid> <الإصدار> 3.1 </الإصدار> <executions> <executions> <id> id> الافتراضي compile </id> <id> الافتراضي-testCompile </fid> <phase> اختبار الاختبار </phase> <irod> <irod> testCompile </siro> </execution> </execution> </plugin> <convin> <id> الاختبار الافتراضي </id> <fase> اختبار </phase> <irod> <irod> اختبار </tord> </execution> </evention> </executions> </suncloy> <clupin> <load> تثبيت </tord> </forts> </evelop> </executions> </sugnein> <clupin> <trictifactid> maven-deploy-plugin </shintifactid> <الإصدار> 2.7 </exection> <evelop> <evelop> <evid> </executions> </suplosin> <compint> <StifactId> maven-site-plugin </stifactid> <الإصدار> 3.3 </version> <evelopmentions> <evelop> <id> الموقع الافتراضي </id> <fase> الموقع </phase> 2015/hellocetc/target/site </ourcedirectory> <upervePlugins> <reterplugin> <rouplud> org.apache.maven.plugins </groupId> <StifactId> maven-project-proports> exection </exemberplugins> execution </exemberplugins </exemberplugins </exemberplugins </exemberplugins </exemberplugin> <id> default-deploy </d> <phase> site-deploy </phare> <irod> <irod> نشر </tome> </exply> <configuration> <tourdDirectory> d:/user/a/workpaces/myeclipse 2015/hellocetc/target/site </outputdirectory> <roupiD> org.apache.maven.plugins </groupId> <StifactId> maven-project-info-proports-plugin </stifactid> </reportplugin> </reportplugins> </reportPlugins> </configuration> 2015/Hellocetc/Target/Site </ourcedirectory> <uptrectPlugins> <reterplugin> <rouplud> org.apache.maven.plugins </groupid> <StifactId> maven-project-info-pluports-plugin </stiftIdActid> </reportplugin <reutying> <utputDirectory> d:/user/a/workpaces/myeclipse 2015/hellocetc/target/site </outputdirectory> </retracting> </project> [info] --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2015-11-18T20: 05: 12+08: 00 [معلومات] الذاكرة النهائية: 10m/245m [معلومات] -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ما سبق هو كل محتوى هذه المقالة. آمل أن يكون ذلك مفيدًا لتعلم الجميع وآمل أن يدعم الجميع wulin.com أكثر.