這期內容當中小編將會給大家帶來有關怎么進行自定義spring-boot-starter,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
網站建設哪家好,找創新互聯!專注于網頁設計、網站建設、微信開發、小程序設計、集團企業網站建設等服務項目。為回饋新老客戶創新互聯還提供了昂仁免費建站歡迎大家使用!
springboot規定一般官網的包名為 spring-boot-start-xxx (spring-boot-start-web)
個人或者第三方命名規則為:xxx-spring-boot-start (pagehelper-spring-boot-start)
當前為可引入jar包,我們創建maven創建項目; springboot 項目默認打包jar為 可執行文件,如果要更改成 可引入jar包,則需要更改為
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>exec</classifier> </configuration> </plugin>
詳細內容不多解釋自行查看
//pageHelper 引入包結構為 - |- pagehlper.jar |- pagehelper-spring-boot-autoconfigure.jar |- pagehelper-spring-boot-starter.jar //自定義包結構為 - white-spring-boot |- white-spring-boot-autoconfigure 自動配置類 |- white-spring-boot-starter 加載類 |- white-core 核心邏輯
當前為空項目,主要內容新增文件
resources/META-INF/spring.provides
pageHelper 中引用的是如下,
provides: pagehelper-spring-boot-autoconfigure,pagehelper,mybatis-spring-boot-autoconfigure,mybatis,mybatis-spring
仿照寫
white-spring-boot-starter 中引用的是
provides: white-core, white-spring-boot-autoconfigure
仿照pagehelper-spring-boot-autoconfigure
創建啟動加載文件
resources/META-INF/spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.apple.WhiteAutoConfiguration
創建com.apple.WhiteAutoConfiguration
@Configuration @EnableConfigurationProperties(WhiteProperties.class) public class WhiteAutoConfiguration { } @ConfigurationProperties(prefix = "white") @Getter @Setter public class WhiteProperties { private Properties properties = new Properties(); public Properties getProperties() { return this.properties; } private String userName; private Integer age; }
源碼 github
上述就是小編為大家分享的怎么進行自定義spring-boot-starter了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注創新互聯行業資訊頻道。
分享題目:怎么進行自定義spring-boot-starter
網站路徑:http://vcdvsql.cn/article18/gjoigp.html
成都網站建設公司_創新互聯,為您提供網站導航、微信公眾號、定制網站、做網站、網站設計、品牌網站制作
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯