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)