构建maven Java项目

来源:互联网 发布:弗洛伊德算法详解 编辑:程序博客网 时间:2024/04/29 21:57

maven项目结构模板


官网提供了常用的模板:
https://maven.apache.org/archetype/maven-archetype-bundles/index.html


构建项目实践

使用模板快速生成项目

mvn archetype:generate -DgroupId=com.app -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstart

 pom.xml 配置

1)可执行jar包app.jar ,依赖包放在与app.jar并行的lib目录下
<build><finalName>app</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><configuration><archive><manifest><addClasspath>true</addClasspath><classpathPrefix>lib/</classpathPrefix><mainClass>com.app.Launcher</mainClass></manifest><manifestEntries><Class-Path>.</Class-Path></manifestEntries></archive></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy</id><phase>test</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>target/lib</outputDirectory></configuration></execution></executions></plugin>...</plugins>...</build>


2)


                                             
0 0
原创粉丝点击