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)文章
使用RestTemplate調(diào)用https接口跳過證書驗證
這篇文章主要介紹了使用RestTemplate調(diào)用https接口跳過證書驗證,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-10-10SpringBoot使用Redis對用戶IP進(jìn)行接口限流的示例詳解
使用接口限流的主要目的在于提高系統(tǒng)的穩(wěn)定性,防止接口被惡意打擊,這篇文章主要介紹了SpringBoot使用Redis對用戶IP進(jìn)行接口限流的示例代碼,需要的朋友可以參考下2023-07-07apollo更改配置刷新@ConfigurationProperties配置類
這篇文章主要為大家介紹了apollo更改配置刷新@ConfigurationProperties配置類示例解析,apollo更改配置刷新@ConfigurationProperties配置類2023-04-04Spring Boot的應(yīng)用啟動與關(guān)閉的方法
本篇文章主要介紹了Spring Boot的應(yīng)用啟動與關(guān)閉的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12SpringBoot+SpringSecurity 不攔截靜態(tài)資源的實現(xiàn)
這篇文章主要介紹了SpringBoot+SpringSecurity 不攔截靜態(tài)資源的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09Java中Cookie和Session詳解及區(qū)別總結(jié)
這篇文章主要介紹了Java中Cookie和Session詳解,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下2022-06-06