首先 用IDEA 打包出错,因为需要把JAR包发布到本地maven仓库中,IDEA优先从本项目中查找JAR包,提示XX包找不到,具体原因官网和度娘有很多,所以我用命令行打包。
部署流程大致为:
- 部署jar包到本地maven仓库
- 部署jar包
开始上代码
首先你要有一个maven仓库,类似于这样婶儿的,并且设置允许更新(重要!!!)。
image.png
然后再maven 的setting.xml中配置它
image.png
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>密码不能告诉你</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>密码不能告诉你</password>
</server>
</servers>
父项目pom
<groupId>com.rgsc</groupId>
<artifactId>rgsc</artifactId>
<version>1.0.0</version>
<name>rgsc</name>
<description>rgsc</description>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.name>spring-boot-v2</project.build.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<installed>${project.build.directory}/installed</installed>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
。。。。。。。。。。。。
。。。。。。。。。。。。
</dependencies>
<modules>
<module>rgsc-frame</module>
<module>rgsc-account</module>
<module>rgsc-main</module>
<module>rgsc-domain</module>
<module>rgsc-device</module>
<module>rgsc-production-monitoring</module>
<module>rgsc-data-select</module>
<module>rgsc-dispatch</module>
<module>rgsc-early-warning-settings</module>
<module>rgsc-bigdata</module>
<module>rgsc-app</module>
<module>rgsc-websocket</module>
<module>rgsc-common</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<mainClass>com.rgsc.main.MainApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Releases</name>
<url>http://192.168.7.67:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Snapshot</name>
<url>http://192.168.7.67:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
重要位置
image.png
image.png
子项目pom
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rgsc</groupId>
<artifactId>rgsc-frame</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>rgsc-frame</name>
<description>框架</description>
<parent>
<groupId>com.rgsc</groupId>
<artifactId>rgsc</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
</project>
重要位置,此处springboot官网有说明,大致是exec的jar包才可以被引用,再问就哭
所有的将被其他项目引用的子项目 都需要配置 这个 (重要)!!!!
配置基本就好了,然后再父项目根目录执行命令:
mvn deploy
mvn clean install -DskipTests
放几张图证明下我不是乱写的
本地maven仓库本地docker仓库 jenkins工作区
jenkins列表
多云是因为前几次调试脚本造成的,以上
网友评论