Maven部署多个可执行jar

时间:2019-01-28 15:16:29

标签: java maven deployment

我有一个项目,带有以下pom.xml:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>imon_api</id>
                        <configuration>
                            <attach>true</attach>
                            <archive>
                                <manifest>
                                    <mainClass>imon.api.Application</mainClass>
                                </manifest>
                            </archive>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <finalName>imon_api-${project.version}</finalName>
                        </configuration>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>imon_server</id>
                        <configuration>
                            <attach>true</attach>
                            <archive>
                                <manifest>
                                    <mainClass>imon.server.Application</mainClass>
                                </manifest>
                            </archive>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <finalName>imon_server-${project.version}</finalName>
                        </configuration>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>


                </executions>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>imon_api</id>
                        <configuration>
                            <attach>true</attach>
                            <mainClass>com.sysmech.zen.services.imon.api.Application</mainClass>
                            <finalName>imon_api-${project.version}</finalName>
                        </configuration>
                        <phase>package</phase>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>imon_server</id>
                        <configuration>
                            <attach>true</attach>
                            <mainClass>com.sysmech.zen.services.imon.server.Application</mainClass>
                            <finalName>imon_server-${project.version}</finalName>
                        </configuration>
                        <phase>package</phase>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>

“ mvn软件包”已构建:

  • target / imon-1.0.0-SNAPSHOT.jar
  • target / imon_api-1.0.0-SNAPSHOT.jar
  • target / imon_api-1.0.0-SNAPSHOT-jar-with-dependencies.jar
  • target / imon_server-1.0.0-SNAPSHOT.jar
  • target / imon_server-1.0.0-SNAPSHOT-jar-with-dependencies.jar

我想要哪一个:在Artifactory中部署imon_api-1.0.0-SNAPSHOT.jar和imon_server-1.0.0-SNAPSHOT.jar。但是,发生了什么:

[INFO]将target / imon_server-1.0.0-SNAPSHOT.jar安装到〜/ .m2 / repository ... / imon / 1.0.0-SNAPSHOT / imon-1.0.0-SNAPSHOT.jar

因此,将imon_server文件部署为imon-1.0.0-SNAPSHOT.jar,并且未部署imon_api。

知道为什么吗?

更新: 实际上,看起来最后执行是重命名为imon-1.0.0-SNAPSHOT.jar的执行。因此,如果我更改执行顺序,则api将被重命名。

0 个答案:

没有答案