maven打包所有依賴對外提供sdk.jar
maven打包所有依賴對外提供sdk.jar
maven打包所有依賴
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compile.source>1.8</maven.compile.source>
<maven.compile.target>1.8</maven.compile.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${maven.compile.source}</source>
<target>${maven.compile.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<!--<manifest>-->
<!--<mainClass>com.quan.simple.IncFrame</mainClass>-->
<!--</manifest>-->
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>如何讓引入自己sdk的spring掃描sdk下的類
新建配置類(@Import注解可以加載指定類至spring容器中)
import com.xxx.sso.aop.SsoCheckAspect;
import org.springframework.context.annotation.Import;
/**
* 自動配置類
*
* @author ccyy
*/
@Import({SsoCheckAspect.class})
public class SsoConfiguration {
}新建如下目錄以及文件

maven 打包將依賴打進(jìn)jar包
最近在做JAVA 的SDK 工具,由于SDK 依賴了其他的一些開源工具包,打包時少了依賴工具包,這樣其他項目想要用SDK 就需要自己額外增加響應(yīng)依賴,所以想要把依賴打進(jìn)SDK。
其實這也很簡單,只需要更改maven 配置即可,有如下幾個步驟:
1. 修改pom 文件
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>xxx-xxx-sdk</finalName>
<descriptorRefs>
<!-- 將依賴的jar包中的class文件打進(jìn)生成的jar包-->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!-- 可以增加main函數(shù)入口,可有可無-->
<mainClass>com.xxx.xxx.xxx</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>在打包時就會多出一個 xxx-xxx-sdk.jar
到此這篇關(guān)于maven打包所有依賴,對外提供sdk.jar的文章就介紹到這了,更多相關(guān)maven打包依賴內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Java 集合框架之List 的使用(附小游戲練習(xí))
這篇文章主要介紹Java 集合框架中List 的使用,下面文章將圍繞Java 集合框架中List 的使用展開話題,并附上一些小游戲練習(xí),需要的朋友可以參考一下2021-10-10
在SpringBoot項目中使用JetCache緩存的詳細(xì)教程
Spring Boot是一個非常流行的Java開發(fā)框架,JetCache是一個基于注解的高性能緩存框架,本文將介紹如何在Spring Boot項目中使用JetCache緩存,并提供一個詳細(xì)案例來說明如何配置和使用JetCache,需要的朋友可以參考下2024-06-06
Java中List和fastjson的JSONArray相互轉(zhuǎn)換代碼示例
這篇文章主要介紹了如何在Java中將List和JSONArray相互轉(zhuǎn)換,展示了如何將List轉(zhuǎn)換為JSONArray,并且可以直接運行這段代碼,需要的朋友可以參考下2025-04-04
解決java轉(zhuǎn)義json出現(xiàn)\u0000 等亂碼的問題
這篇文章主要介紹了解決java轉(zhuǎn)義json出現(xiàn)\u0000 等亂碼的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-03-03

