이 기사는 Maven을 사용하여 실행 가능한 JAR 패키지를 생성하는 방법을 소개합니다. 그것은 당신과 공유됩니다. 세부 사항은 다음과 같습니다.
POM의 XSI에서 POM을 설명하는 스키마를 열 수 있습니다.
POM에서 프로젝트의 구조를 볼 수 있습니다.
기본 MVN 설치로 생성 된 JAR에는 메인 클래스 항목이 없으며 메인 클래스는 Maven-Commiple-Plugin으로 설정해야합니다.
<project xmlns = "http://maven.apache.org/pom/4.0.0"xmlns : xsi = "http://www.w3.org/2001/xmlschema-instance"xsi : schemalocation = "http://maven.apache.org/pom/0.0.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelversion> 4.0.0 </modelversion> <groupid> com.cetc.di </groupid> <artifactid> hellocetc </artifactid> <version> 0.0.1-snapshot> </packshot> <이름> hellocetc </name> <url> http://maven.apache.org </url> <properties> <project.build.build.sourceencoding> utf-8 </project.build.sourceencoding> </properties> <pections> <prection> </groupid> <artifactid> <버전> 3.8.1 </version> <scope> 테스트 </scope> </fectionency> </fectionements> <build> <fluginmanagement> <플러그인> <플러그인> <groupid> org.apache.maven.plugins </groupid> <artifactid> maven-jar-pplugin </artifactid> <configupation> 1.8 source> </target> 1.8 <Archive> <minifest> <mainclass> com.cetc.di.hellocetc.app </mainclass> <dadclasspath> true </addclasspath> <classpathprefix> lib/</classpathprefix> </manifest> </archive> <classeCectory> </flugation> </configuration> </pluginmanagement> </build> </project>
MVN 설치 실행 :
대상 디렉토리에서 JAR 패키지가 생성 된 것으로 나타났습니다.
Java Decompiler를 사용하면 MainClass가 매니페스트에 추가되었음을 알 수 있습니다.
MVN 도움말 : 효과적인 POM을 사용하여 POM.XML의 전체 구조 (상속 특성 포함) :
[정보] 프로젝트 스캔 ... [정보] [정보] ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 적용 : <!- ======================================================================= ======================================================================== ======================================================================== ======================================================================== ======================================================================== ======================================================================== ======================================================================== =========================================================================== ======================================================================== =========================================================================== =========================================================================== =========================================================================== =========================================================================== =========================================================================== =========================================================================== =========================================================================== ============================================================================= --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns : xsi = "http://www.w3.org/2001/xmlschema-instance"xsi : schemalocation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.0.xsd" <modeversion> 4.0.0 </modelversion> <groupid> com.cetc.di </groupid> <artifactid> hellocetc </artifactid> <snapshot </version> <name> hellocetc </name> <url> http://maven.apache.org </url> <project.build.sourceencoding> utf-8 </project.build.build.sourceencoding> </properties> <pectional> <pectionement> <groupid> junit> <artifactid> junit </artifactid> <bersion> <berifactid> </scope </scopies> </dependency> <repository> <snapshots> <enabled> false </enabled> </snapshots> </id> Central </id> <name> Central Repository </name> <url> https://repo.maven.apache.org/maven2 </url> </repository> </repository> </repository> </repository> <Releases> <ududfolicy> never </updatePolicy> </releases> <snapshots> <anabled> false </enabled> </enabled> </snapshots> <id> Central </id> <name> 중앙 저장소 </name> <url> https://repo.maven.apache.org/maven2 </pluginpository> </pluginepository>> <Sourcedirectory> d :/user/a/workspaces/myeclipse 2015/hellocetc/src/main/java </sourcedirectory> <scriptsourcedirectory> d :/users/a/workspaces/myeclipse 2015/hellocetc/src/main/scripts </scriptsourctory> <testsourcedirectory> d :/user/a/strages/mylipse 2015/hellocetc/src/test/java </testsourcedirectory> <outputdirectory> d :/user/a/workspaces/myeclipse 2015/hellocetc/target/classs </outputdirectory> <TestOutputDirectory> d :/user/a/workspaces/myeclipse 2015/hellocetc/target/test-classes </testoutputdirectory> <resource> <resource> <directory> d :/user/a/workspaces/myeclipse 2015/hellocetc/src/main/resources> </rounters> <testresources> <Directory> D :/Users/A/WorkSpaces/MyEclipse 2015/HelloCETC/SRC/Test/Resources </directory> </testResources> </testResources> <Directory> d :/user/a/workspaces/myeclipse 2015/hellocetc/target </direction> </hellocetc-0.0.0.0.1-snapshot <PluginManagement> <flugins> <ArtifactID> Maven-Antrun-Plugin </artifactid> <bersion> 1.3 </version> </plugin> <flugin> <Artifactid> Maven-Assembly-Plugin </artifactid> <bersion> 2.2-beta-5 </plugin> <Artifactid> Maven-Dependency-Plugin </artifactid> <bersion> 2.8 </version> </version> </plugin> <artifactid> maven reelease-plugin </artifactid> <version> 2.3.2 </version> </plugin> <artifactid> </version> </artifactid> 버전>. <configuration> <court> 1.8 </source> <garget> 1.8 </target> <아카이브> <mainclass> <mainclass> com.cetc.app </mainclass> <dadclasspath> true </addclasspath> <classpathprefix> lib/</classpatprefix> <classitive> </archive> </archive> </플러그인> </plugins> </pluginsmanagement> <플러그인> <artifactid> maven-clean-plugin </artifactid> <version> </version> <executions> <execution> <id> default-clean </id> <stage> </phase> <goving> </govent> </execution> </execution> </execution> </execution> <Artifactid> Maven-Resources-Plugin </artifactid> <bersion> 2.6 </version> <executions> <executions> <executions> <id> default-testresources </id> <case> 프로세스-테스트-자원 </phase> <goving> <Goal> testresources </bock </govent> </gualution> <id> default-resources resources </execution> <execution> <id> 기본 재료 </id> <case> Process-Resources </phase> <Goal Goal> <Goal> Resources </Goal> </execution> </plugin> <ArtifactID> Maven-Jar-Plugin </artifactid> </version> <id </id> <case> 패키지 </phase> <goving> goal> jar </goal> </goals> <configuration> <court> 1.8 </source> <garget> 1.8 </target> <아카이브> <mainclass> com.cetc.di.hellocetc.app </mainclass> <dudclasspit> true </classpitpref </classpix> </manifest> </archive> <classsDirectory/> </configuration> </execution> </executions> <configuration> <source> 1.8 </source> <garget> 1.8 </target> <Archive> <Archive> <MainClass> com.cetc.di.hellocetc.app </mainclass> </addclass </addclass </mainclass> com.cetc. <classpathprefix> lib/</classpathprefix> </manifest> </archive> <classeDirectory/> </configuration> </plugin> <flugin> <artifactid> maven-compiler-plugin </artifactid> <bersion> 3.1 </version> <execution> <id> compile> <GOARKILE> </GOOM> </GOALS> </execution> <execution> <id> Default-TestCompile </id> <case> 테스트-컴파일 </phase> <goving> <goving> </govent> </execution> </execution> </execution> <artifactid> Maven-Surefin </execution </execution </execution </execution> </execution </execution </execution> <버전> 2.12.4 </version> <executions> <executions> <execution> <id> default-test </id> <case> test> </phase> </phase> </phase> </phase> </phase> </plugin> </plugin> <plugin> <artifactid> <version> </version> </version> </version> <ID> 기본 정보 설치 </id> <단계> install </phase> <goation> goalge </pase> </guall> install </guall> </govent> </executions> </plugin> <flugin> <artifactid> maven-deploy-plugin </artifactid> </version> </version> <execution> <id> provely deploy </id> proploy </Goal> 배포 </govel> </goals> </execution> </executions> </plugin> <Flugin> <Flugin> <ArtifActId> Maven-Site-Plugin </artifactid> <bersion> 3.3 </version> <execution> <id> default-site </id> <phase> site </phase> <목표> 사이트 </goal> </gual> </gubating> <outputDirectory> d :/user/a/workspaces/myeclipse 2015/hellocetc/target/site </outputDirectory> <reportPlugins> <reportPlugin> <groupId> org.apache.maven.plugins </groupid> maven-project-info-reports-plugin- </reportplugins> </reportplugins> </configuration> </execution> <execution> <id> 기본 날짜 </id> <case> site-deploy </phase> <goving> <govel> 배포 </govel> </govent> <configuration> <outputDirectory> d :/user/a/workspaces/myeclipse 2015/hellocetc/sitec/sitec/sitec/sitec/sitec/sitec/sitec/myeclipse <reportplugins> <reportplugin> <groupid> org.apache.maven.plugins </groupid> <artifactid> maven-project-info-reports-plugin </artifactid> </reportPlugin> </reportPlugins> </reportPlugins> </configution> </execution> </execution> </reportPlugins> </reportPlugins> </reportPlugins> <outputDirectory> d :/user/a/workspaces/myeclipse 2015/hellocetc/target/site </outputDirectory> <reportPlugins> <reportPlugin> <groupId> org.apache.maven.plugins </groupid> maven-project-info-reports-plugin- </reportplugins> </configuration> </plugin> </plugins> </build> <보고> <outputdirectory> d :/users/a/a workspaces/myeclipse 2015/hellocetc/target/site </outputDirectory> </reporting> </project> [info] ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2015-11-18T20 : 05 : 12+08 : 00 [정보] 최종 메모리 : 10m/245m [정보] -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.