主頁 > 後端開發 > SpringBoot(9)自定義Starter

SpringBoot(9)自定義Starter

2022-07-18 08:33:53 後端開發

自定義Starter

如果Spring Boot自帶的入口類不能滿足要求,則可以自定義Starter,自定義Starter的步驟 如下,

1.引入必要的依賴

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-test</artifactId>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>org.projectlombok</groupId>
	<artifactId>lombok</artifactId>
	<optional>true</optional>
</dependency>

2.自定義Properties類

在使用Spring官方的Starter時,可以在application.properties檔案中配置引數,以覆寫默認值,在自定義Starter時,也可以根據需要來配置Properties類,以保存配置資訊,見以下代碼:

package com.itheima.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "spring.mystarter")
public class MyStarterProperties {
    private String parameter;
    public String getParameter() {
        return parameter;
    }
    public void setParameter(String parameter) {
        this.parameter = parameter;
    }
}

3.定義核心服務類

每個Starter都需要有自己的功能,所以需要定義服務類,如:

package com.itheima.properties;

public class MyStarter {
    private MyStarterProperties myProperties;

    public MyStarter() {
    }
    public MyStarter(MyStarterProperties myProperties) {
        this.myProperties = myProperties;
    }
    public String print(){
        System.out.println("引數:"+myProperties.getParameter());
        String result = myProperties.getParameter();
        return result;
    }
}

4.定義自動配置類

每個Starter —般至少有一個自動配置類,命名規則為“名字+AutoConfiguration”,如MyStarterServiceAutoConfiguration, 配置方法見以下代碼:

package com.itheima.properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MyStarterProperties.class)
@ConditionalOnClass(MyStarter.class)
@ConditionalOnProperty(prefix = "spring.mystarter",value = "https://www.cnblogs.com/liwenruo/archive/2022/07/17/enabled",matchIfMissing = true)
public class MyStartServiceConfiguration {
    @Autowired
    private MyStarterProperties myStarterProperties = new MyStarterProperties();
    @Bean
    @ConditionalOnMissingBean(MyStarter.class)
    public MyStarter myStarterService(){
        MyStarter myStarter = new MyStarter(myStarterProperties);
        return myStarter;
    }
}

最后,在resources檔案夾下新建目錄META-INF,在目錄中新建spring.factories檔案, 并且在spring.factories中配置AutoConfiguration,加入以下代碼: 

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
  com.itheima.properties.MyStartServiceConfiguration

注解詳解:

??使用

??ConfigurationProperties:

??外部化配置的注釋,如果您想系結和驗證一些外部屬性(例如,來自 .properties 檔案),請將其添加到類定義或@Configuration類中的@Bean方法中,系結可以通過在帶注釋的類上呼叫 setter 來執行,或者,如果正在使用@ConstructorBinding ,則通過系結到建構式引數來執行,請注意,與@Value相反,SpEL 運算式不會被評估,因為屬性值是外部化的,

??原始碼解釋:

表示一個類宣告了一個或多個@Bean方法,并且可以被 Spring 容器處理以在運行時為這些 bean 生成 bean 定義和服務請求,例如:
   @Configuration
   public class AppConfig {
       @Bean
       public MyBean myBean() {
           // instantiate, configure and return bean ...
       }
   }
引導@Configuration類
通過AnnotationConfigApplicationContext
@Configuration類通常使用AnnotationConfigApplicationContext或其支持 Web 的變體AnnotationConfigWebApplicationContext進行引導,前者的簡單示例如下:
   AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
   ctx.register(AppConfig.class);
   ctx.refresh();
   MyBean myBean = ctx.getBean(MyBean.class);
   // use myBean ...
   
有關詳細資訊,請參閱AnnotationConfigApplicationContext javadocs,有關Servlet容器中的 Web 配置說明,請參閱AnnotationConfigWebApplicationContext ,
通過 Spring <beans> XML
作為直接針對AnnotationConfigApplicationContext注冊@Configuration類的替代方法, @Configuration類可以在 Spring XML 檔案中宣告為普通的<bean>定義:
   <beans>
      <context:annotation-config/>
      <bean />
   </beans>
   
在上面的示例中,需要<context:annotation-config/>以啟用ConfigurationClassPostProcessor和其他有助于處理@Configuration類的注釋相關的后處理器,
通過組件掃描
@Configuration使用@Component進行元注釋,因此@Configuration類是組件掃描的候選物件(通常使用 Spring XML 的<context:component-scan/>元素),因此也可以像任何常規@Component一樣利用@Autowired / @Inject @Component ,特別是,如果存在單個建構式,則自動裝配語意將透明地應用于該建構式:
   @Configuration
   public class AppConfig {
  
       private final SomeBean someBean;
  
       public AppConfig(SomeBean someBean) {
           this.someBean = someBean;
       }
  
       // @Bean definition using "SomeBean"
  
   }
@Configuration類不僅可以使用組件掃描進行引導,還可以使用@ComponentScan注解配置組件掃描:
   @Configuration
   @ComponentScan("com.acme.app.services")
   public class AppConfig {
       // various @Bean definitions ...
   }
有關詳細資訊,請參閱@ComponentScan javadocs,
使用外化值
使用Environment API
可以通過將 Spring org.springframework.core.env.Environment注入@Configuration類來查找外部化的值——例如,使用@Autowired注釋:
   @Configuration
   public class AppConfig {
  
       @Autowired Environment env;
  
       @Bean
       public MyBean myBean() {
           MyBean myBean = new MyBean();
           myBean.setName(env.getProperty("bean.name"));
           return myBean;
       }
   }
通過Environment決議的屬性駐留在一個或多個“屬性源”物件中, @Configuration類可以使用@PropertySource注釋將屬性源貢獻給Environment物件:
   @Configuration
   @PropertySource("classpath:/com/acme/app.properties")
   public class AppConfig {
  
       @Inject Environment env;
  
       @Bean
       public MyBean myBean() {
           return new MyBean(env.getProperty("bean.name"));
       }
   }
有關更多詳細資訊,請參閱Environment和@PropertySource javadocs,
使用@Value注釋
可以使用@Value注釋將外部化的值注入到@Configuration類中:
   @Configuration
   @PropertySource("classpath:/com/acme/app.properties")
   public class AppConfig {
  
       @Value("${bean.name}") String beanName;
  
       @Bean
       public MyBean myBean() {
           return new MyBean(beanName);
       }
   }
這種方法通常與 Spring 的PropertySourcesPlaceholderConfigurer結合使用,可以通過<context:property-placeholder/>在 XML 配置中自動啟用,或者通過專用的static @Bean方法在@Configuration類中顯式啟用(參見“關于 BeanFactoryPostProcessor-returning @Bean方法”的@Bean的 javadocs 的詳細資訊),但是請注意,通常僅當您需要自定義配置(例如占位符語法等)時才需要通過static @Bean方法顯式注冊PropertySourcesPlaceholderConfigurer ,特別是,如果沒有 bean 后處理器(例如PropertySourcesPlaceholderConfigurer )已注冊作為ApplicationContext的嵌入式值決議器,Spring 將注冊一個默認的嵌入式值決議器,它根據在Environment中注冊的屬性源決議占位符,請參閱下面有關使用@ImportResource使用 Spring XML 組合@Configuration類的部分;參見@Value javadocs;有關使用BeanFactoryPostProcessor型別(例如PropertySourcesPlaceholderConfigurer )的詳細資訊,請參閱@Bean javadocs,
組合@Configuration類
使用@Import注釋
@Configuration類可以使用@Import注解組成,類似于<import>在 Spring XML 中的作業方式,因為@Configuration物件在容器中作為 Spring bean 進行管理,所以可以注入匯入的配置——例如,通過建構式注入:
   @Configuration
   public class DatabaseConfig {
  
       @Bean
       public DataSource dataSource() {
           // instantiate, configure and return DataSource
       }
   }
  
   @Configuration
   @Import(DatabaseConfig.class)
   public class AppConfig {
  
       private final DatabaseConfig dataConfig;
  
       public AppConfig(DatabaseConfig dataConfig) {
           this.dataConfig = dataConfig;
       }
  
       @Bean
       public MyBean myBean() {
           // reference the dataSource() bean method
           return new MyBean(dataConfig.dataSource());
       }
   }
現在AppConfig和匯入的DatabaseConfig都可以通過僅針對 Spring 背景關系注冊AppConfig來引導:
   new AnnotationConfigApplicationContext(AppConfig.class);
使用@Profile注釋
@Configuration類可以用@Profile注釋標記,以表明只有在給定的組態檔或組態檔處于活動狀態時才應處理它們:
   @Profile("development")
   @Configuration
   public class EmbeddedDatabaseConfig {
  
       @Bean
       public DataSource dataSource() {
           // instantiate, configure and return embedded DataSource
       }
   }
  
   @Profile("production")
   @Configuration
   public class ProductionDatabaseConfig {
  
       @Bean
       public DataSource dataSource() {
           // instantiate, configure and return production DataSource
       }
   }
或者,您也可以在@Bean方法級別宣告組態檔條件 - 例如,對于同一配置類中的替代 bean 變體:
   @Configuration
   public class ProfileDatabaseConfig {
  
       @Bean("dataSource")
       @Profile("development")
       public DataSource embeddedDatabase() { ... }
  
       @Bean("dataSource")
       @Profile("production")
       public DataSource productionDatabase() { ... }
   }
有關更多詳細資訊,請參閱@Profile和org.springframework.core.env.Environment javadocs,
使用@ImportResource注解的 Spring XML
如上所述, @Configuration類可以在 Spring XML 檔案中宣告為常規 Spring <bean>定義,也可以使用@ImportResource注釋將 Spring XML 組態檔匯入@Configuration類,可以注入從 XML 匯入的 Bean 定義——例如,使用@Inject注解:
   @Configuration
   @ImportResource("classpath:/com/acme/database-config.xml")
   public class AppConfig {
  
       @Inject DataSource dataSource; // from XML
  
       @Bean
       public MyBean myBean() {
           // inject the XML-defined dataSource bean
           return new MyBean(this.dataSource);
       }
   }
使用嵌套@Configuration類
@Configuration類可以相互嵌套,如下所示:
   @Configuration
   public class AppConfig {
  
       @Inject DataSource dataSource;
  
       @Bean
       public MyBean myBean() {
           return new MyBean(dataSource);
       }
  
       @Configuration
       static class DatabaseConfig {
           @Bean
           DataSource dataSource() {
               return new EmbeddedDatabaseBuilder().build();
           }
       }
   }
當引導這樣的安排時,只需要針對應用程式背景關系注冊AppConfig ,由于是嵌套的@Configuration類, DatabaseConfig將自動注冊,當AppConfig和DatabaseConfig之間的關系已經隱式明確時,這避免了使用@Import注釋的需要,
還要注意,嵌套的@Configuration類可以與@Profile注釋一起使用,從而為封閉的@Configuration類提供同一個bean 的兩個選項,
配置延遲初始化
默認情況下, @Bean方法將在容器引導時急切地實體化,為了避免這種情況,@ @Lazy @Configuration一起使用,以指示在類中宣告的所有@Bean方法默認情況下都是惰性初始化的,請注意, @Lazy也可以用于單個@Bean方法,
測驗對@Configuration類的支持
spring-test模塊中可用的 Spring TestContext 框架提供了@ContextConfiguration注解,它可以接受一組組件類參考——通常是@Configuration或@Component類,
   @RunWith(SpringRunner.class)
   @ContextConfiguration(classes = {AppConfig.class, DatabaseConfig.class})
   public class MyTests {
  
       @Autowired MyBean myBean;
  
       @Autowired DataSource dataSource;
  
       @Test
       public void test() {
           // assertions against myBean ...
       }
   }
有關詳細資訊,請參閱TestContext 框架 參考檔案,
使用@Enable注解啟用內置 Spring 功能
Spring 特性,如異步方法執行、計劃任務執行、注釋驅動的事務管理,甚至 Spring MVC 都可以使用它們各自的“ @Enable ”注釋從@Configuration類中啟用和配置,有關詳細資訊,請參閱@EnableAsync 、 @EnableScheduling 、 @EnableTransactionManagement 、 @EnableAspectJAutoProxy和@EnableWebMvc ,
創作@Configuration類時的約束
配置類必須作為類提供(即不是作為從工廠方法回傳的實體),允許通過生成的子類進行運行時增強,
配置類必須是非最終的(允許在運行時使用子類),除非proxyBeanMethods標志設定為false ,在這種情況下不需要運行時生成的子類,
配置類必須是非本地的(即不能在方法中宣告),
任何嵌套的配置類都必須宣告為static ,
@Bean方法可能不會反過來創建進一步的配置類(任何此類實體都將被視為常規 bean,它們的配置注釋仍然未被檢測到),

??EnableConfigurationProperties:

??啟用對@ConfigurationProperties注釋 bean 的支持, @ConfigurationProperties bean 可以以標準方式注冊(例如使用@Bean方法),或者為了方便起見,可以直接在此注釋上指定,

??ConditionalOnClass:

??@Conditional僅在指定的類在類路徑上時匹配,可以在@Configuration類上安全地指定value() ,因為在加載類之前使用 ASM 決議注釋元資料,放置在@Bean方法上時需要格外小心,考慮將條件隔離在單獨的Configuration類中,特別是如果方法的回傳型別與target of the condition匹配,

??ConditionalOnProperty:

??@Conditional檢查指定屬性是否具有特定值,默認情況下,屬性必須存在于Environment中并且不等于false , havingValue()和matchIfMissing()屬性允許進一步自定義,
havingValue屬性可用于指定屬性應具有的值,

5.打包發布

在完成上面的配置后,打包生成JAR檔案,然后就可以像使用官方Starter那樣使用了,如果不發布到Maven中心倉庫,則需要用戶手動添加依賴,

6.創建用于測驗Starter的專案

在創建新頊目后,如果要添加自定義的Starter依賴,則不能用添加官Starter的方法,因為 此時還未將Starter發布到Maven中心倉庫,只能通過開發工具匯入此依賴JAR檔案(在IDEA 中,通過單擊選單欄的 FILE—>ProjectStructure—>Modules—>Dependencies,然后單擊+號,選擇   JARs or directories......選項添加依賴),然后,配置 application.properties檔案,加入以下引數:

spring.mystarter.parameter=buretuzi

7.使用starter

在需要使用的地方注入依賴即可,具體使用見以下代碼:
@Autowired
private MyStarter myStarterService;
@Test
public void hello(){
    System.out.println(myStarterService.print());
}

正規的Starter是一個獨立的工程,可以在Maven中的新倉庫注冊發布,以便幵發人員使用,

自定義Starter包括以下幾個方面的內容,

  • 自動組態檔:根據classpath是否存在指定的類來決定是否要執行該功能的自動配置,
  • factories:指導Spring Boot找到指定的自動組態檔,
  • endpoint:包含對服務的描述、界面、互動(業務資訊的查詢),
  • health indicator:該Starter提供的服務的健康指標,

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/499562.html

標籤:其他

上一篇:【Python】檔案操作中的a,a+,w,w+幾種方式的區別_轉

下一篇:java中抽象類和介面有什么不同呢?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more