我正在使用Maven构建可执行文件Spring-Boot,并且还使用了spring-boot-maven-plugin。
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.psmonster.wfe</groupId>
<artifactId>saxon</artifactId>
<packaging>jar</packaging>
<version>0.1.1</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<pluginRepositories>
<pluginRepository>
<id>maven2</id>
<url>https://repo.maven.apache.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-B</artifactId>
<version>9.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-consul-dependencies</artifactId>
<version>1.0.0.RELEASE</version>
<type>pom</type>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>central</id>
<name>saxon-releases</name>
<url>${env.MAVEN_REPO_URL}/repository/WFESRV/</url>
</repository>
</distributionManagement>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>base.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
运行此命令时:
mvn $MAVEN_CLI_OPTS clean package spring-boot:repackage -Dmaven.test.skip=true -q
myPSMonster.jar的构建良好,我可以在Docker容器中运行它。 因此,我只想将其推送到Nexus Artifactory,只需在重新打包后添加 deploy 。 然后,将覆盖漂亮的jar,并推送仅包含已编译代码的小jar。
有人知道如何在不使用deploy:deploy-file的情况下解决此问题吗?
答案 0 :(得分:1)
为什么不使用maven deploy插件来部署存档。还有其他插件可以执行此任务。而且,如果您使用的是jenkins,则可以通过jenkins插件对部署设置进行不同的管理。但是就目前而言,我们可以在本地计算机上使用maven来设置带有链接服务器凭据的.m2 settings file
。之后,您可以使用以下命令配置pom.xml
:
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>${repository_url}</url>
</snapshotRepository>
</distributionManagement>
以上部分将告诉Maven在部署过程中将工件推送到何处。安装完成后,您可以使用插件:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin
Maven部署插件链接到Maven生命周期的deployment
阶段。然后,您可以使用以下命令将jar / war推送到存储库中:
mvn clean deploy -Dmaven.test.skip=true
答案 1 :(得分:0)
所以。最终它使用以下方法解决了这个问题:
- mvn $MAVEN_CLI_OPTS deploy:deploy-file -DpomFile=pom.xml -DrepositoryId=central
-Dfile=target/saxon-0.1.$CI_PIPELINE_ID.jar
-Durl=http://psmonster:8081/repository/WFESRV/