最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

關(guān)于SpringBoot自定義條件注解與自動配置

 更新時間:2023年07月13日 10:00:02   作者:潮浪之巔  
這篇文章主要介紹了關(guān)于SpringBoot自定義條件注解與自動配置,Spring Boot的核心功能就是為整合第三方框架提供自動配置,而本文則帶著大家實(shí)現(xiàn)了自己的自動配置和Starter,需要的朋友可以參考下

Spring Boot的核心功能就是為整合第三方框架提供自動配置,而本文則帶著大家實(shí)現(xiàn)了自己的自動配置和Starter,一旦真正掌握了本文的內(nèi)容,就會對Spring Boot產(chǎn)生“一覽眾山小”的感覺。

自定義條件注解

在SpringBoot中,所有自定義條件注解其實(shí)都是基于@Conditional而來的,使用@Conditional定義新條件注解關(guān)鍵就是要有一個Condition實(shí)現(xiàn)類,該Condition實(shí)現(xiàn)類就負(fù)責(zé)條件注解的處理邏輯,該實(shí)現(xiàn)類所實(shí)現(xiàn)的matches()方法決定了條件注解的要求是否得到滿足。

下面是自定義條件注解的Condition實(shí)現(xiàn)類的代碼。

  • src/main/java/com/example/_003configtest/condition/MyCondition.java
package com.example._003configtest.condition;
import com.example._003configtest.annotation.ConditionalCustom;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import java.util.Map;
public class MyCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //獲取@ConditionalCustom注解的全部屬性,其中ConditionalCustom是自定義的注解
        Map<String, Object> annotationAttributes = metadata.getAnnotationAttributes(ConditionalCustom.class.getName());
        //獲取注解的value屬性值
        String[] vals = (String[]) annotationAttributes.get("value");
        //env是application.properties或application.yml中配置的屬性
        Environment env = context.getEnvironment();
        //遍歷每個value的每個屬性值
        for (String val : vals) {
            //如果某個屬性值對應(yīng)的配置屬性不存在,則返回false
            if(env.getProperty(val.toString())== null){
                return false;
            }
        }
        return true;
    }
}

從上面的邏輯可以看到,自定義條件注解的處理邏輯比較簡單:就是要求value屬性所指定的所有配置屬性必須存在,至于這些配置屬性的值是什么無所謂,這些配置屬性是否有值也無所謂。

有了上面的Condition實(shí)現(xiàn)類之后,接下來即可基于@Conditional來定義自定義條件注解。下面是自定義條件注解的代碼。

  • src/main/java/com/example/_003configtest/annotation/ConditionalCustom.java
package com.example._003configtest.annotation;
import com.example._003configtest.condition.MyCondition;
import org.springframework.context.annotation.Conditional;
import java.lang.annotation.*;
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
//只要通過@Conditional指定Condition實(shí)現(xiàn)類即可,該Condition實(shí)現(xiàn)類就會負(fù)責(zé)該條件注解的判斷邏輯
@Conditional(MyCondition.class)
public @interface ConditionalCustom {
    String[] value() default {};
}

下面的配置類示范了如何使用該自定義的條件注解:

  • src/main/java/com/example/_003configtest/config/MyConfigTest.java
// proxyBeanMethods = true  :單例模式,保證每個@Bean方法被調(diào)用多少次返回的組件都是同一個
// proxyBeanMethods = false :原型模式,每個@Bean方法被調(diào)用多少次返回的組件都是新創(chuàng)建的
@Configuration(proxyBeanMethods = true)
public class MyConfigTest {
    @Bean
    //只有當(dāng)applicaion.properties或application.yml中org.test1,org.test2兩個配置屬性都存在時才生效
    @ConditionalCustom({"org.test1","org.test2"})
    public MyBean myBean(){
        return new MyBean();
    }
}

在application.properties文件中添加如下配置:

org.test1 = 1
org.test2 = 2

運(yùn)行測試發(fā)現(xiàn)成功獲得了容器中對應(yīng)的類:

image-20220608230844951

自定義自動配置

開發(fā)自己的自動配置很簡單,其實(shí)也就兩步:

  1. 使用@Configuration和條件注解定義自動配置類。
  2. 在META-INF/spring.factories文件中注冊自動配置類。

為了清楚地演示Spring Boot自動配置的效果,避免引入第三方框架導(dǎo)致的額外復(fù)雜度,本例先自行開發(fā)一個funny框架,該框架的功能是用文件或數(shù)據(jù)庫保存程序的輸出信息。

新建一個Maven項(xiàng)目funny(注意不是用SpringInitializr創(chuàng)建項(xiàng)目),為該項(xiàng)目添加mysql-connector-java和slf4j-api兩個依賴。由于該項(xiàng)目是我們自己開發(fā)的框架,因此無須為該項(xiàng)目添加任何Spring Boot依賴。下面是該項(xiàng)目的pom.xml文件代碼。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>funny</artifactId>
    <version>1.0-SNAPSHOT</version>
    <!-- 定義所使用的Java版本和源代碼使用的字符集-->
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <!-- MySQL數(shù)據(jù)庫驅(qū)動依賴 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.27</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.36</version>
        </dependency>
    </dependencies>
</project>

接下來為這個框架項(xiàng)目開發(fā)如下類。

  • src/main/java/io/WriterTemplate.java
package io;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;
import javax.sql.DataSource;
public class WriterTemplate {
    Logger log = LoggerFactory.getLogger(this.getClass());
    private final DataSource dataSource;
    private Connection conn;
    private File dest;
    private final Charset charset;
    private RandomAccessFile raf;
    public WriterTemplate(DataSource dataSource) throws SQLException {
        this.dataSource = dataSource;
        this.dest = null;
        this.charset = null;
        if(Objects.nonNull(this.dataSource)){
            log.debug("========獲取數(shù)據(jù)庫連接========");
            this.conn = dataSource.getConnection();
        }
    }
    public WriterTemplate(File dest,Charset charset) throws FileNotFoundException{
        this.dest = dest;
        this.charset = charset;
        this.dataSource = null;
        this.raf = new RandomAccessFile(this.dest,"rw");
    }
    public void write(String message) throws IOException,SQLException{
        if(Objects.nonNull(this.conn)){
            //查詢當(dāng)前數(shù)據(jù)庫的fnny_message表是否存在
            ResultSet rs = conn.getMetaData().getTables(conn.getCatalog(),null,"funny_message",null);
            //如果funy_message表不存在,需要創(chuàng)建表
            if(!rs.next()){
                log.debug("~~~~~~~~~創(chuàng)建funny_message表~~~~~~~~~");
                conn.createStatement().execute("create table funny_message " + "(id int primary key auto_increment,message_text text)");
            }
            log.debug("~~~~~~~~~輸出到數(shù)據(jù)表~~~~~~~~~");
            //往數(shù)據(jù)庫中插入數(shù)據(jù)
            conn.createStatement().executeUpdate("insert into " + "funny_message values(null,'" + message + "')");
            rs.close();
        }
        else{
            log.debug("~~~~~~~~~輸出到文件~~~~~~~~~");
            raf.seek(this.dest.length());
            raf.write((message + "\n").getBytes(this.charset));
        }
    }
    //關(guān)閉資源
    public void close() throws SQLException,IOException{
        if(this.conn != null){
            this.conn.close();
        }
        if(this.raf != null){
            this.raf.close();
        }
    }
}

該工具類根據(jù)是否傳入 DataSource 來決定輸出目標(biāo):如果為該工具類傳入了DataSource,它就會向該數(shù)據(jù)源所連接的數(shù)據(jù)庫中的funny_message表輸出內(nèi)容(如果該表不存在,該工具類將會自動建表);如果沒有為該工具類傳入DataSource,它就會向指定文件輸出內(nèi)容。

接下來使用install打包到maven倉庫:

image-20220609112738611

有了該框架之后,接下來為該框架開發(fā)自動配置。如果為整合現(xiàn)有的第三方框架開發(fā)自動配置,則可直接從這一步開始(因?yàn)榭蚣芤呀?jīng)存在了,直接為框架開發(fā)自動配置即可)。

同樣新建一個Maven項(xiàng)目funny-spring-boot-starter(為了方便可以用SpringInitializr創(chuàng)建項(xiàng)目),這個項(xiàng)目是自定義Starter項(xiàng)目,因此必須要有Spring Boot支持,將前面Spring Boot項(xiàng)目中的pom.xml文件復(fù)制過來,保留其中的spring-boot-starter依賴,并添加剛剛開發(fā)的funny框架的依賴。此外,由于該項(xiàng)目不是Spring Boot應(yīng)用,因此不需要主類,也不需要運(yùn)行,故刪除其中的spring-boot-maven-plugin插件。修改后的pom.xml文件內(nèi)容如下。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>funny-spring-boot-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>funny-spring-boot-starter</name>
    <description>funny-spring-boot-starter</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
    </properties>
    <dependencies>
        <!-- Spring Boot Starter依賴-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <!-- 依賴自定義的funny框架,如果正在為其他第三方框架開發(fā)自動配置,則此處應(yīng)該填寫被整合的第三方框架的坐標(biāo)。-->
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>funny</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

接下來定義如下自動配置類。

  • src/main/java/com/example/funnyspringbootstarter/autoconfig/FunnyAutoConfiguration.java
package com.example.funnyspringbootstarter.autoconfig;
import io.WriterTemplate;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import javax.xml.crypto.Data;
import java.io.File;
import java.io.FileNotFoundException;
import java.nio.charset.Charset;
import java.sql.SQLException;
@Configuration
//當(dāng)WriteTemplate類存在時配置生效
@ConditionalOnClass(WriterTemplate.class)
//FunnyProperties是自定義的類,后面會定義,這里表示啟動FunnyProperties
@EnableConfigurationProperties(FunnyProperties.class)
//讓該自動配置類位于DataSourceAutoConfiguration自動配置類之后處理
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class FunnyAutoConfiguration {
    private final FunnyProperties properties;
	//FunnyProperties類負(fù)責(zé)加載配置屬性
    public FunnyAutoConfiguration(FunnyProperties properties) {
        this.properties = properties;
    }
    @Bean(destroyMethod = "close")
    //當(dāng)單例的DataSource Bean存在時配置生效
    @ConditionalOnSingleCandidate(DataSource.class)
    //只有當(dāng)容器中沒有WriterTemplate Bean時,該配置才會生效
    @ConditionalOnMissingBean
    //通過@AutoConfigureOrder注解指定該配置方法比下一個配置WriterTemplate的方法的優(yōu)先級更高
    @AutoConfigureOrder(99)
    public WriterTemplate writerTemplate(DataSource dataSource) throws SQLException{
        return new WriterTemplate(dataSource);
    }
    @Bean(destroyMethod = "close")
    //只有當(dāng)前面的WriteTemplate配置沒有生效時,該方法的配置才會生效
    @ConditionalOnMissingBean
    @AutoConfigureOrder(199)
    public WriterTemplate writerTemplate2() throws FileNotFoundException{
        File f = new File(this.properties.getDest());
        Charset charset = Charset.forName(this.properties.getCharset());
        return new WriterTemplate(f,charset);
    }
}

在FunnyAutoConfiguration 自動配置類中定義了兩個@Bean方法,這兩個@Bean 方法都用于自動配置 WriterTemplate。為了指定它們的優(yōu)先級,程序使用了@AutoConfigureOrder 注解修飾它們,該注解指定的數(shù)值越小,優(yōu)先級越高。

FunnyAutoConfiguration 自動配置類中的@Bean 方法同樣使用了@ConditionalOnMissingBean`@ConditionalOnSingleCandidate等條件注解修飾,從而保證只有當(dāng)容器中不存在WriterTemplate時,該自動配置類才會配置WriterTemplate Bean,且優(yōu)先配置基于DataSource的WriterTemplate。

上面的自動配置類還用到了FunnyProperties屬性處理類,該類的代碼如下:

package com.example.funnyspringbootstarter.autoconfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = FunnyProperties.FUNNY_PREFIX)
public class FunnyProperties {
    public static final String FUNNY_PREFIX = "org.test";
    private String dest;
    private String charset;
    public String getDest() {
        return dest;
    }
    public void setDest(String dest) {
        this.dest = dest;
    }
    public String getCharset() {
        return charset;
    }
    public void setCharset(String charset) {
        this.charset = charset;
    }
}

上面的屬性處理類負(fù)責(zé)處理以“org.test”開頭的屬性,這個“org.test”是必要的,它相當(dāng)于這一組配置屬性的“命名空間”,通過這個命名空間可以將這些配置屬性與其他框架的配置屬性區(qū)分開。

有了上面的自動配置類之后,接下來使用如下META-INF/spring.factories文件來注冊自動配置類。

  • src/main/resources/META-INF/spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration = \
  com.example.funnyspringbootstarter.autoconfig.FunnyAutoConfiguration

經(jīng)過上面步驟,自動配置開發(fā)完成,接下來使用install打包到maven倉庫:

image-20220609125306059

有了自定義的Starter之后,接下來使用該Starter與使用Spring Boot官方Starter并沒有任何區(qū)別。首先新建一個Maven項(xiàng)目myfunnytest,在pom文件中引入該starter:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>myfunnytest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>myfunnytest</name>
    <description>myfunnytest</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>funny-spring-boot-starter</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-starter</artifactId>-->
<!--        </dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.7.RELEASE</version>
                <configuration>
                    <mainClass>com.example.myfunnytest.MyfunnytestApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

由于 funny-spring-boot-starter 本身需要依賴 spring-boot-starter,因此不再需要顯式配置依賴spring-boot-starter。

在添加了上面的funny-spring-boot-starter依賴之后,該Starter包含的自動配置生效,它會嘗試在容器中自動配置WriterTemplate,并且還會讀取application.properties因此還需要在application.properties文件中進(jìn)行配置。

  • src/main/resources/application.properties
# 應(yīng)用名稱
spring.application.name=myfunnytest
org.test.dest = F:/abc-12345.txt
org.test.charset=UTF-8
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDateTimeCode=false&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root

該示例的主類很簡單,它直接獲取容器中的WriterTemplate Bean,并調(diào)用該Bean的write()方法執(zhí)行輸出。下面是該主類的代碼:

package com.example.myfunnytest;
import io.WriterTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
public class MyfunnytestApplication {
    public static void main(String[] args) throws Exception{
        ConfigurableApplicationContext run = SpringApplication.run(MyfunnytestApplication.class, args);
        WriterTemplate writerTemplate = run.getBean(WriterTemplate.class);
        System.out.println(writerTemplate);
        writerTemplate.write("自動配置");
    }
}

運(yùn)行該程序,由于當(dāng)前Spring容器中沒有DataSource Bean,因此FunnyAutoConfiguration將會自動配置輸出到文件的WriterTemplate。因此,運(yùn)行該程序,可以看到程序向“f:/abc-12345.txt”文件(由前面的org.test.dest屬性配置)輸出內(nèi)容:

在這里插入圖片描述

運(yùn)行結(jié)果如下:

image-20220609130748581

如果在項(xiàng)目的pom.xml文件中通過如下配置來添加依賴。

<!--        Spring Boot JDBC Starter依賴-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

此時為項(xiàng)目添加了spring-boot-starter-jdbc依賴,該依賴將會在容器中自動配置一個DataSource Bean,這個自動配置的DataSource Bean將導(dǎo)致FunnyAutoConfiguration會自動配置輸出到數(shù)據(jù)庫的WriterTemplate。因此,運(yùn)行該程序,可以看到程序向數(shù)據(jù)庫名為springboot數(shù)據(jù)庫的funny_message表輸出內(nèi)容:

image-20220609132600694

Spring Boot的核心功能就是為整合第三方框架提供自動配置,而本文則帶著大家實(shí)現(xiàn)了自己的自動配置和Starter,一旦真正掌握了本文的內(nèi)容,就會對Spring Boot產(chǎn)生“一覽眾山小”的感覺。

到此這篇關(guān)于關(guān)于SpringBoot自定義條件注解與自動配置的文章就介紹到這了,更多相關(guān)SpringBoot自定義注解內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • ElasticSearch自定義注解增刪改方式

    ElasticSearch自定義注解增刪改方式

    這篇文章主要介紹了ElasticSearch自定義注解增刪改方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • Spring中依賴注入(DI)幾種方式解讀

    Spring中依賴注入(DI)幾種方式解讀

    這篇文章主要介紹了Spring中依賴注入(DI)幾種方式解讀,構(gòu)造器依賴注入通過容器觸發(fā)一個類的構(gòu)造器來實(shí)現(xiàn)的,該類有一系列參數(shù),每個參數(shù)代表一個對其他類的依賴,需要的朋友可以參考下
    2024-01-01
  • Spring?createBeanInstance實(shí)例化Bean

    Spring?createBeanInstance實(shí)例化Bean

    這篇文章主要為大家介紹了Spring?createBeanInstance實(shí)例化Bean源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • 詳解SpringBoot同時可以處理多少請求

    詳解SpringBoot同時可以處理多少請求

    在日常操作中,相信很多人在SpringBoot能同時處理多少請求問題上存在疑惑,本文就來詳細(xì)的介紹一下,感興趣的可以了解一下
    2024-06-06
  • java模擬多線程http請求代碼分享

    java模擬多線程http請求代碼分享

    本篇文章給大家分享了java模擬多線程http請求的相關(guān)實(shí)例代碼,對此有需要的可以跟著測試下。
    2018-05-05
  • java 四舍五入保留小數(shù)的實(shí)現(xiàn)方法

    java 四舍五入保留小數(shù)的實(shí)現(xiàn)方法

    下面小編就為大家?guī)硪黄猨ava 四舍五入保留小數(shù)的實(shí)現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-09-09
  • 如何利用JAVA實(shí)現(xiàn)走迷宮程序

    如何利用JAVA實(shí)現(xiàn)走迷宮程序

    最近經(jīng)常在機(jī)房看同學(xué)在玩一個走迷宮的游戲,比較有趣,自己也用java實(shí)現(xiàn)了一個,這篇文章主要給大家介紹了關(guān)于如何利用JAVA實(shí)現(xiàn)走迷宮程序的相關(guān)資料,需要的朋友可以參考下
    2021-06-06
  • springboot實(shí)現(xiàn)jar運(yùn)行復(fù)制resources文件到指定的目錄(思路詳解)

    springboot實(shí)現(xiàn)jar運(yùn)行復(fù)制resources文件到指定的目錄(思路詳解)

    這篇文章主要介紹了springboot實(shí)現(xiàn)jar運(yùn)行復(fù)制resources文件到指定的目錄,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-04-04
  • idea項(xiàng)目的左側(cè)目錄沒了如何設(shè)置

    idea項(xiàng)目的左側(cè)目錄沒了如何設(shè)置

    這篇文章主要介紹了idea項(xiàng)目的左側(cè)目錄沒了如何設(shè)置的操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-02-02
  • java利用oss實(shí)現(xiàn)下載功能

    java利用oss實(shí)現(xiàn)下載功能

    這篇文章主要為大家詳細(xì)介紹了java利用oss實(shí)現(xiàn)下載功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-10-10

最新評論

治县。| 上思县| 顺义区| 林周县| 德州市| 安丘市| 大余县| 苏尼特左旗| 岳阳县| 大姚县| 武山县| 上饶市| 开封县| 南京市| 巴楚县| 海口市| 胶州市| 阿拉尔市| 赤壁市| 两当县| 新闻| 霍林郭勒市| 阿荣旗| 方正县| 汶上县| 九台市| 扎赉特旗| 调兵山市| 资阳市| 双城市| 康马县| 塔城市| 灵石县| 锡林浩特市| 皮山县| 尤溪县| 耒阳市| 商河县| 广宁县| 分宜县| 万山特区|