How to package the springCloud project and distribute the jar to the specified directory
The springCloud microservice package jar has too many modules; my project module structure is as follows:
I separated the entity class-related modules into a separate moduleservice-api下
The service is written separately under a block ofservice
,
The jars of each module are in the target directory. It is too troublesome to drag them one by one during deployment, so we can use maven-antrun-plugin
to move the packaged jar package to the specified location. directory, the specific usage is as follows:
maven-antrun-plugin
can usemaven-antrun-plugin
plug-in
<!--要输出jar的路径-->
<properties>
<copy.jar.directory>C:/Users/xxx/Desktop/xxx/springcloudalibaba/xxx/jar/</copy.jar.directory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<configuration>
<target>
<copy todir="${copy.jar.directory}">
<fileset dir="${project.build.directory}">
<include name="${project.artifactId}-${project.version}.jar" />
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Note: For example, for common modules in the project, such as common and entity, there is no need to specify packaging plug-ins in the pom files of some public modules.
You can install the common modules before packaging. Install it into the mavne warehouse at once, and then use clean, package and other plug-ins at the outermost layer of the project to package
In this way, the jar of the module you want to apply to the jar will also be in your jar package :
Just like my job-hunting
entity module, I put it in job-hunting-api
. After executing install, a>job-hunting.jar
Successjob-hunting-api.jar