背景:使用第三方开源软件作为基础框架,在此基础上进行自身业务开发
需求:为代码更加清晰,不直接在开源框架中添加业务代码,而是依赖该框架进行开发,为避免版本冲突,将该开源框架当下的版本上传至私服,后续自身项目依赖该版本,无特殊情况不再对框架版本进行升级
方法:
一、新建项目,将开源框架代码拷贝其中(以ruoyi为例)
二、排除框架自身的配置文件和启动类(不使用springboot的打包插件,仍用maven-jar-plugin)
<plugins> <!-- 发布私服start --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.0</version> <configuration> <excludes> <!-- 排除文件start --> <exclude>application.yml</exclude> <exclude>application-druid.yml</exclude> <exclude>com/ruoyi/RuoYiApplication.class</exclude> <exclude>com/ruoyi/RuoYiServletInitializer.class</exclude> <!-- 排除文件end --> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.1</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9</version> <configuration> <!-- 禁用java 8 的DocLint新特性,以确保当javadoc有编译错误时,也能正常生成javadoc jar包--> <additionalparam>-Xdoclint:none</additionalparam> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <!--mvn目标指令--> <goals>-f pom.xml deploy</goals> </configuration> </plugin> <!-- 发布私服end --> </plugins>
三、定义好私服地址和自定义的maven坐标,上传至私服
mvn deploy