国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

SpringBoot_第七章(讀寫(xiě)分離)

這篇具有很好參考價(jià)值的文章主要介紹了SpringBoot_第七章(讀寫(xiě)分離)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

目錄

1:MybatisPlus(讀寫(xiě)分離)

1.1:首先創(chuàng)建三個(gè)數(shù)據(jù)庫(kù)1主2從

1.2:代碼實(shí)例

1.3:優(yōu)缺點(diǎn)分析

2:SpringBoot路由數(shù)據(jù)源(讀寫(xiě)分離)

2.1:實(shí)現(xiàn)原理

2.2:代碼實(shí)現(xiàn)

2.3:測(cè)試代碼?

2.4:優(yōu)缺點(diǎn)分析


這里列舉了兩種讀寫(xiě)分離實(shí)現(xiàn)方案,如下

1:MybatisPlus(讀寫(xiě)分離)

1.1:首先創(chuàng)建三個(gè)數(shù)據(jù)庫(kù)1主2從

表名是user表

SpringBoot_第七章(讀寫(xiě)分離),框架_SpringBoot,java

SpringBoot_第七章(讀寫(xiě)分離),框架_SpringBoot,java

SpringBoot_第七章(讀寫(xiě)分離),框架_SpringBoot,java

1.2:代碼實(shí)例

1:導(dǎo)入pom


        <!--MybatisPlus的jar 3.0基于jdk8-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3.1</version>
        </dependency>

        <!-- mybatisPlus多數(shù)據(jù)源依賴  實(shí)現(xiàn)讀寫(xiě)分離-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
            <version>3.6.1</version>
        </dependency>

        <!-- mysql的依賴-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.33</version>
        </dependency>

        <!--直接使用druid的starter 連接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.16</version>
        </dependency>

2:配置spring的主從

server:
  port: 8082

spring:
  datasource:
    dynamic:
      primary: master #設(shè)置默認(rèn)的數(shù)據(jù)源或者數(shù)據(jù)源組,默認(rèn)值即為master
      strict: false #嚴(yán)格匹配數(shù)據(jù)源,默認(rèn)false. true未匹配到指定數(shù)據(jù)源時(shí)拋異常,false使用默認(rèn)數(shù)據(jù)源
      datasource:
        master:
          url: jdbc:mysql://localhost:3306/W1?useUnicode=true&characterEncoding=utf-8&useSSL=false
          username: root
          password: 123456
          driver-class-name: com.mysql.cj.jdbc.Driver
          type: com.alibaba.druid.pool.DruidDataSource #配置德魯伊數(shù)據(jù)源
          druid:
            initial-size: 10 #連接池初始化大小
            min-idle: 10 #最小空閑連接數(shù)
            max-active: 20 #最大連接數(shù)

        slave_1:
          url: jdbc:mysql://localhost:3306/W1R1?useUnicode=true&characterEncoding=utf-8&useSSL=false
          username: root
          password: 123456
          driver-class-name: com.mysql.cj.jdbc.Driver
          type: com.alibaba.druid.pool.DruidDataSource #配置德魯伊數(shù)據(jù)源
          druid:
            initial-size: 10 #連接池初始化大小
            min-idle: 10 #最小空閑連接數(shù)
            max-active: 20 #最大連接數(shù)
        slave_2:
          url: jdbc:mysql://localhost:3306/W1R2?useUnicode=true&characterEncoding=utf-8&useSSL=false
          username: root
          password: 123456
          driver-class-name: com.mysql.cj.jdbc.Driver
          type: com.alibaba.druid.pool.DruidDataSource #配置德魯伊數(shù)據(jù)源
          druid:
            initial-size: 10 #連接池初始化大小
            min-idle: 10 #最小空閑連接數(shù)
            max-active: 20 #最大連接數(shù)


        #......省略
        #以上會(huì)配置一個(gè)默認(rèn)庫(kù)master,一個(gè)組slave下有兩個(gè)子庫(kù)slave_1,slave_2


3:代碼實(shí)例 @DS("slave") 注解用來(lái)切換數(shù)據(jù)源

/**
* @description 針對(duì)表【User】的數(shù)據(jù)庫(kù)操作Service實(shí)現(xiàn)
* @createDate 2023-11-01 17:17:57
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{


    @Resource
    UserMapper userMapper;
    
    //多個(gè)從庫(kù) 負(fù)載均衡輪訓(xùn)查詢 也可以注解到類上
    //@DS("slave")
    @DS("slave")
    public User selectRW_S(Integer id) {
        return userMapper.selectById(id);
    }
    //主庫(kù)查詢數(shù)據(jù)
    //@DS("master")
    @DS("master")
    public User selectRW_M(Integer id) {
        return userMapper.selectById(id);
    }

    //無(wú)注解,不指定數(shù)據(jù), 默認(rèn)查詢主庫(kù)
    @Override
    public User selectRW(Integer id) {
        return userMapper.selectById(id);
    }
}

controller代碼根據(jù)請(qǐng)求不同訪問(wèn)不同的數(shù)據(jù)源

@RestController
public class UserControllerRW {

    @Resource
    UserServiceImpl userService;

    //查詢主庫(kù) @DS("master")
    @GetMapping(value = "selectRW1")
    public User selectRW_M(@RequestParam(name = "id",required = true) Integer id){
        User user = userService.selectRW_M(id);
        System.out.println(user);
        return user;
    }

    //查詢從庫(kù) @DS("slave") 輪訓(xùn)查詢
    @GetMapping(value = "selectRW2")
    public User selectRW_S(@RequestParam(name = "id",required = true) Integer id){
        User user = userService.selectRW_S(id);
        System.out.println(user);
        return user;
    }

    //無(wú)注解,不指定數(shù)據(jù), 默認(rèn)查詢主庫(kù)
    @GetMapping(value = "selectRW3")
    public User selectRW(@RequestParam(name = "id",required = true) Integer id){
        User user = userService.selectRW(id);
        System.out.println(user);
        return user;
    }
}

查詢結(jié)果截圖

SpringBoot_第七章(讀寫(xiě)分離),框架_SpringBoot,java

SpringBoot_第七章(讀寫(xiě)分離),框架_SpringBoot,java

SpringBoot_第七章(讀寫(xiě)分離),框架_SpringBoot,java

1.3:優(yōu)缺點(diǎn)分析

dynamic-datasource的jar包的官方文檔

基礎(chǔ)必讀(免費(fèi)) · dynamic-datasource · 看云

本框架只做切換數(shù)據(jù)的事情,不限制你的具體操作,從庫(kù)也可以增刪改查,讀寫(xiě)分離只是他的一個(gè)小功能,分庫(kù)分表要自己實(shí)現(xiàn)

  • 支持?數(shù)據(jù)源分組?,適用于多種場(chǎng)景 純粹多庫(kù) 讀寫(xiě)分離 一主多從 混合模式。
  • 支持?jǐn)?shù)據(jù)庫(kù)敏感配置信息?加密(可自定義)?ENC()。
  • 支持每個(gè)數(shù)據(jù)庫(kù)獨(dú)立初始化表結(jié)構(gòu)schema和數(shù)據(jù)庫(kù)database。
  • 支持無(wú)數(shù)據(jù)源啟動(dòng),支持懶加載數(shù)據(jù)源(需要的時(shí)候再創(chuàng)建連接)。
  • 支持?自定義注解?,需繼承DS(3.2.0+)。
  • 提供并簡(jiǎn)化對(duì)Druid,HikariCp,BeeCp,Dbcp2的快速集成。
  • 提供對(duì)Mybatis-Plus,Quartz,ShardingJdbc,P6sy,Jndi等組件的集成方案。
  • 提供?自定義數(shù)據(jù)源來(lái)源?方案(如全從數(shù)據(jù)庫(kù)加載)。
  • 提供項(xiàng)目啟動(dòng)后?動(dòng)態(tài)增加移除數(shù)據(jù)源?方案。
  • 提供Mybatis環(huán)境下的?純讀寫(xiě)分離?方案。
  • 提供使用?spel動(dòng)態(tài)參數(shù)?解析數(shù)據(jù)源方案。內(nèi)置spel,session,header,支持自定義。
  • 支持?多層數(shù)據(jù)源嵌套切換?。(ServiceA >>> ServiceB >>> ServiceC)。
  • 提供?基于seata的分布式事務(wù)方案?。
  • 提供?本地多數(shù)據(jù)源事務(wù)方案。

2:SpringBoot路由數(shù)據(jù)源(讀寫(xiě)分離)

2.1:實(shí)現(xiàn)原理

實(shí)現(xiàn)方案是通過(guò)在spring容器中注入多個(gè)數(shù)據(jù)源,通過(guò)不同的key來(lái)找到指定的數(shù)據(jù)源,AbstractRoutingDataSource的源碼知道,AbstractRoutingDataSource里邊通過(guò)Map可以過(guò)個(gè)數(shù)據(jù)源,通過(guò)key查找。

2.2:代碼實(shí)現(xiàn)

1:maven依賴?

 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

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

     
        <!--mybatis依賴-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>3.0.2</version>
        </dependency>

        <!--aop依賴-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>


        <!-- mysql的依賴-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.33</version>
        </dependency>

        <!--直接使用druid的starter 連接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.16</version>
        </dependency>
        
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>

    </dependencies>

2:配置數(shù)據(jù)源的1主2從的application.properties

#讀寫(xiě)分離數(shù)據(jù)源配置
#讀寫(xiě)分離數(shù)據(jù)源配置
#配置主數(shù)據(jù)庫(kù)
spring.datasource.master.jdbc-url=jdbc:mysql://localhost:3306/W1?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.master.username=root
spring.datasource.master.password=123456
spring.datasource.master.driver-class-name=com.mysql.cj.jdbc.Driver

#配置讀數(shù)據(jù)庫(kù)1
spring.datasource.read1.jdbc-url=jdbc:mysql://localhost:3306/W1R1?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.read1.username=root
spring.datasource.read1.password=123456
spring.datasource.read1.driver-class-name=com.mysql.cj.jdbc.Driver


#配置讀數(shù)據(jù)庫(kù)2
spring.datasource.read2.jdbc-url=jdbc:mysql://localhost:3306/W1R2?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.read2.username=root
spring.datasource.read2.password=123456
spring.datasource.read2.driver-class-name=com.mysql.cj.jdbc.Driver

3:代碼注入多個(gè)數(shù)據(jù)源

@Configuration
public class MyDataSourceConfig {

    /**
     * 主庫(kù)
     * @return
     */
    @Bean(value = "master")
    @ConfigurationProperties(prefix = "spring.datasource.master")
    public DataSource masterDataSource(){
        return DataSourceBuilder.create().build();
    }

    /**
     * 從庫(kù)1
     * @return
     */
    @Bean(value = "read1")
    @ConfigurationProperties(prefix = "spring.datasource.read1")
    public DataSource read1DataSource(){
        return DataSourceBuilder.create().build();
    }


    /**
     * 從庫(kù)2
     * @return
     */
    @Bean(value = "read2")
    @ConfigurationProperties(prefix = "spring.datasource.read2")
    public DataSource read2DataSource(){
        return DataSourceBuilder.create().build();
    }


    /**
     * 配置4個(gè)數(shù)據(jù)源 1個(gè)路由數(shù)據(jù)源 3個(gè)自定義數(shù)據(jù)源
     * 自定義的路由數(shù)據(jù)源
     * @return
     */
    @Bean(value = "myRoutingDataSource")
    public DataSource myRoutingDataSource(@Qualifier(value="master")DataSource master,
                                        @Qualifier(value="read1")DataSource read1,
                                        @Qualifier(value="read2") DataSource read2){

        //自定義路由數(shù)據(jù)源
        MyRoutingDataSource routingDataSource=new MyRoutingDataSource();
        //目標(biāo)數(shù)據(jù)源 master  read1 read2
        Map<Object, Object> targetDataSources=new HashMap<>();
        targetDataSources.put("master",master);
        targetDataSources.put("read1",read1);
        targetDataSources.put("read2",read2);
        //放入默認(rèn)數(shù)據(jù)源是 master
        routingDataSource.setDefaultTargetDataSource(master);
        routingDataSource.setTargetDataSources(targetDataSources);
        return routingDataSource;
    }


}

?4:數(shù)據(jù)源切換代碼實(shí)現(xiàn)

public class DBContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal();
    private static final AtomicInteger count = new AtomicInteger(1);

    //ThreadLocal的get、set方法設(shè)置數(shù)據(jù)源
    public static String get() {
        return contextHolder.get();
    }
    public static void set(String dataSource) {
        contextHolder.set(dataSource);
    }

    public static void remove() {
        contextHolder.remove();
    }

    /**
     * 獲取 主數(shù)據(jù)庫(kù)
     */
    public static void master() {
        set("master");
        System.out.println("切換到master數(shù)據(jù)源");
    }

    /**
     * 獲取從數(shù)據(jù)庫(kù) 隨機(jī)獲取 或者隨機(jī)獲取
     */
    public static void read() {
//        //輪詢數(shù)據(jù)源進(jìn)行讀操作
//        Random random=new Random();
//        int index = random.nextInt(10);
//        System.out.println("隨機(jī)數(shù):"+index);
//        if(index>5){
//            set("read1");
//            System.out.println("切換到read1數(shù)據(jù)源");
//        }else {
//            set("read2");
//            System.out.println("切換到read2數(shù)據(jù)源");
//        }

        int index = count.getAndIncrement()%2;
        System.out.println("模數(shù):" + index);
        System.out.println("隨機(jī)數(shù):" + count);

        //輪詢數(shù)據(jù)源進(jìn)行讀操作
        if (count.get() > 10) {
            count.set(1);
        }
        if (index == 0) {
            set("read1");
            System.out.println("切換到slave1數(shù)據(jù)源");
        } else {
            set("read2");
            System.out.println("切換到slave2數(shù)據(jù)源");
        }

    }

    public static void main(String[] args) {
        //輪詢數(shù)據(jù)源進(jìn)行讀操作
        Random random = new Random();
        int index = random.nextInt(10);
        System.out.println(index);
    }

}

5:獲取路由數(shù)據(jù)源

/**
 * 自定義路由數(shù)據(jù)源 繼承AbstractRoutingDataSource
 */
public class MyRoutingDataSource extends AbstractRoutingDataSource {

    /**
     *  通過(guò)指定的key來(lái)確認(rèn)當(dāng)前的數(shù)據(jù)源方法
     *
     *  目標(biāo)數(shù)據(jù)源 master  read1  read2
     *         Map<Object, Object> targetDataSources=new HashMap<>();
     *         targetDataSources.put("master",master);
     *         targetDataSources.put("read1",read1);
     *         targetDataSources.put("read2",read2);
     *
     *
     *  根據(jù)Aop 在執(zhí)行不同方法之前  設(shè)置不同的數(shù)據(jù)源的key
     */

    @Override
    protected Object determineCurrentLookupKey() {
        return DBContextHolder.get();
    }
}

?6:mybatis的數(shù)據(jù)源配置

/**
 * mybatis的數(shù)據(jù)源配置
 * 由于Spring容器中現(xiàn)在有4個(gè)數(shù)據(jù)源,所以我們需要為事務(wù)管理器和MyBatis手動(dòng)指定一個(gè)明確的數(shù)據(jù)源。
 */
@Configuration
public class MyBatisConfig {

    @Resource(name = "myRoutingDataSource")
    private DataSource myRoutingDataSource;

    @Bean
    public SqlSessionFactory sqlSessionFactory() throws Exception {
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        sqlSessionFactoryBean.setDataSource(myRoutingDataSource);
        sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));
        return sqlSessionFactoryBean.getObject();
    }

    @Bean
    public PlatformTransactionManager platformTransactionManager() {
        return new DataSourceTransactionManager(myRoutingDataSource);
    }
}

7:AOP切入處理,在service方法中通過(guò)切面提前設(shè)置數(shù)據(jù)源的key

@Aspect
@Component
public class DataSourceAop {

    /**
     * 不存在自定義的Master注解
     * 所有service包下的的所有select和get方法 
     * 設(shè)置為讀從庫(kù)數(shù)據(jù)
     */
    @Pointcut("!@annotation(com.example.springboot08_rw1.annotation.Master) " +
            "&& (execution(* com.example.springboot08_rw1.service..*.select*(..)) " +
            "|| execution(* com.example.springboot08_rw1.service..*.get*(..)))")
    public void readPointcut() {

    }

    /**
     * 存在Master注解或者add insert等方法 去主庫(kù)操作
     */
    @Pointcut("@annotation(com.example.springboot08_rw1.annotation.Master) " +
            "|| execution(* com.example.springboot08_rw1.service..*.insert*(..)) " +
            "|| execution(* com.example.springboot08_rw1.service..*.add*(..)) " +
            "|| execution(* com.example.springboot08_rw1.service..*.update*(..)) " +
            "|| execution(* com.example.springboot08_rw1.service..*.edit*(..)) " +
            "|| execution(* com.example.springboot08_rw1.service..*.delete*(..)) " +
            "|| execution(* com.example.springboot08_rw1.service..*.remove*(..))")
    public void writePointcut() {
    }


    @Before("readPointcut()")
    public void read() {
        DBContextHolder.read();
    }


    @Before("writePointcut()")
    public void write() {
        DBContextHolder.master();
    }

//    /**
//     * 另一種寫(xiě)法:if...else...  判斷哪些需要讀從數(shù)據(jù)庫(kù),其余的走主數(shù)據(jù)庫(kù)
//     */
//    @Before("execution(* com.example.springboot08_rw1.service.UserServiceImpl.select*(..))")
//    public void before(JoinPoint jp) {
//        String methodName = jp.getSignature().getName();
//        System.out.println("方法名字:"+methodName);
        if (StringUtils.startsWithAny(methodName, "get", "select", "find")) {
        }else {
            DBContextHolder.master();
        }
//
//        DBContextHolder.read();
//
//    }

}




//自定義注解

public @interface Master {
}

2.3:測(cè)試代碼?

service代碼

@Service
public class UserServiceImpl implements  UserService {
    @Resource
    UserMapper userMapper;
    
    /**
     * 添加自定義注解  @Master 主庫(kù)查詢
     */
    @Master
    public User selectById_Master(Integer id) {
        return userMapper.selectById(1);
    }

    /**
     *  不使用注解  走從庫(kù)查詢
     */
    public User selectById_MoRen(Integer id) {
        return userMapper.selectById(1);
    }

    /**
     * 不使用注解 add方法 走主庫(kù)
     */
    public User add(Integer id) {
        return userMapper.selectById(1);
    }
}

controller層的代碼測(cè)試

@RestController
public class UserController {

    @Autowired
    UserServiceImpl userService;

    //兩個(gè)從庫(kù)切換查詢
    @GetMapping(value = "selectUser")
    public User select(){
       return userService.selectById_MoRen(1);
    }
    //使用注解 查詢主庫(kù)
    @GetMapping(value = "selectUser1")
    public User select1(){
        return userService.selectById_Master(1);
    }
    //方法是add 查詢主庫(kù)
    @GetMapping(value = "selectUser2")
    public User select2(){
        return userService.add(1);
    }
}

頁(yè)面效果

http://localhost:8082/selectUser兩個(gè)從切換查詢

http://localhost:8082/selectUser1主庫(kù)查詢

http://localhost:8082/selectUser2主庫(kù)查詢

2.4:優(yōu)缺點(diǎn)分析

SpringBoot讀寫(xiě)分離_springboot 讀寫(xiě)分離-CSDN博客

代碼比較復(fù)雜,需要制定好spring的數(shù)據(jù)源切換的基礎(chǔ)原理,分庫(kù)分表代碼進(jìn)一步負(fù)載話文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-738437.html

到了這里,關(guān)于SpringBoot_第七章(讀寫(xiě)分離)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 第七章金融中介

    ?? ? ? ? 金融中介是通過(guò)向資金盈余者發(fā)行 間接融資合約( 如存款單),并和資金短缺者達(dá)成 間接投資合約 (發(fā)放信貸)或購(gòu)買其發(fā)行的證券,在資金供求方之間融通資金,對(duì)資金跨期、跨域進(jìn)行優(yōu)化配置的金融機(jī)構(gòu)。 ? ? ? ? 金融體系由金融市場(chǎng)和金融中介構(gòu)成,以銀行業(yè)為

    2024年02月04日
    瀏覽(27)
  • python第七章(字典)

    python第七章(字典)

    一。字典(類型為dict)的特點(diǎn): 1.符號(hào)為大括號(hào) 2.數(shù)據(jù)為鍵值對(duì)形式出現(xiàn) 3.各個(gè)鍵值對(duì)之間以逗號(hào)隔開(kāi) 格式:str1={\\\'name\\\':\\\'Tom\\\'}? name相當(dāng)于鍵值(key),Tom相當(dāng)于值 二??兆值涞膭?chuàng)建方法 三。字典的基本操作(增刪改查) 1.字典的增加操作:字典序列[key] = 值 注意點(diǎn):如果存

    2024年01月24日
    瀏覽(46)
  • 第七章 測(cè)試

    第七章 測(cè)試

    7.1.1 選擇程序設(shè)計(jì)語(yǔ)言 1. 計(jì)算機(jī)程序設(shè)計(jì)語(yǔ)言基本上可以分為匯編語(yǔ)言和高級(jí)語(yǔ)言 2. 從應(yīng)用特點(diǎn)看,高級(jí)語(yǔ)言可分為基礎(chǔ)語(yǔ)言、結(jié)構(gòu)化語(yǔ)言、專用語(yǔ)言 01 有理想的模塊化機(jī)制; 02 可讀性好的控制結(jié)構(gòu)和數(shù)據(jù)結(jié)構(gòu); 03 便于調(diào)試和提高軟件可靠性; 04 編譯程序發(fā)現(xiàn)程序錯(cuò)誤的

    2024年02月08日
    瀏覽(29)
  • [JavaScript] 第七章 對(duì)象

    [JavaScript] 第七章 對(duì)象

    ??作者主頁(yè):青花鎖 ??簡(jiǎn)介:Java領(lǐng)域優(yōu)質(zhì)創(chuàng)作者??、Java微服務(wù)架構(gòu)公號(hào)作者?? ??簡(jiǎn)歷模板、學(xué)習(xí)資料、面試題庫(kù)、技術(shù)互助 ??文末獲取聯(lián)系方式 ?? [Java項(xiàng)目實(shí)戰(zhàn)] 介紹Java組件安裝、使用;手寫(xiě)框架等 [Aws服務(wù)器實(shí)戰(zhàn)] Aws Linux服務(wù)器上操作nginx、git、JDK、Vue等 [Java微服務(wù)

    2024年02月02日
    瀏覽(61)
  • 數(shù)據(jù)結(jié)構(gòu)第七章

    數(shù)據(jù)結(jié)構(gòu)第七章

    圖(Graph)G由兩個(gè)集合V和E組成,記為G=(V, E),其中V是頂點(diǎn)的有窮非空集合,E是V中頂點(diǎn)偶對(duì)的有窮集合,這些頂點(diǎn)偶對(duì)稱為邊。V(G)和E(G)通常分別表示圖G的頂點(diǎn)集合和邊集合,E(G)可以為空集。若EG)為空,則圖G只有頂點(diǎn)而沒(méi)有邊。 子圖:假設(shè)有兩個(gè)圖G=(V,E)和G1=(V1,E1);如果V1

    2024年02月03日
    瀏覽(27)
  • Flink第七章:狀態(tài)編程

    Flink第七章:狀態(tài)編程

    Flink第一章:環(huán)境搭建 Flink第二章:基本操作. Flink第三章:基本操作(二) Flink第四章:水位線和窗口 Flink第五章:處理函數(shù) Flink第六章:多流操作 Flink第七章:狀態(tài)編程 這次我們來(lái)學(xué)習(xí)Flink中的狀態(tài)學(xué)習(xí)部分,創(chuàng)建以下scala文件 這個(gè)文件里有幾個(gè)常用的狀態(tài)創(chuàng)建 按鍵分區(qū)中值狀態(tài)編程案

    2024年02月06日
    瀏覽(24)
  • C國(guó)演義 [第七章]

    C國(guó)演義 [第七章]

    力扣鏈接 給兩個(gè)整數(shù)數(shù)組 nums1 和 nums2 ,返回 兩個(gè)數(shù)組中 公共的 、長(zhǎng)度最長(zhǎng)的子數(shù)組的長(zhǎng)度 。 示例 1: 輸入:nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] 輸出:3 解釋:長(zhǎng)度最長(zhǎng)的公共子數(shù)組是 [3,2,1] 。 示例 2: 輸入:nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0] 輸出:5 提示: 1 = nums1.length, num

    2024年02月10日
    瀏覽(23)
  • 第七章 面向?qū)ο缶幊蹋ɑA(chǔ))

    (1)類是抽象的,概念的,代表一類事物,比如人類、貓類...?即它是數(shù)據(jù)類型。 (2)對(duì)象是具體的,實(shí)際的,代表一個(gè)具體事物,即實(shí)例。 (3)類是對(duì)象的模板,對(duì)象是類的一個(gè)個(gè)體,對(duì)應(yīng)一個(gè)實(shí)例。 屬性是類的一個(gè)組成部分,一般是基本數(shù)據(jù)類型,也可是引用類型(對(duì)

    2024年02月06日
    瀏覽(22)
  • OpenCV:第七章、圖像變換

    OpenCV:第七章、圖像變換

    目錄 第七章:圖像變換 7.1、基于OpenCV的邊緣檢測(cè) 7.1.1、一般步驟 1、濾波 2、增強(qiáng) 3、檢測(cè) 7.1.2、canny算子 1、canny算子簡(jiǎn)介 2、canny邊緣檢測(cè)的步驟 7.2、霍夫變換? 7.2.2、OpenCV中的霍夫線變換 7.2.3、霍夫線變換原理? ? ? ? 7.2.4、標(biāo)準(zhǔn)霍夫變換:HoughLines()函數(shù) ? ?7.2.5、累計(jì)概率

    2024年02月03日
    瀏覽(20)
  • 第七章 正則表達(dá)式

    第七章 正則表達(dá)式

    目錄 1.1. 概念: 1.2. 基本正則表達(dá)式 1.2.1. 常見(jiàn)元字符 1.2.2. POSIX字符類 1.2.3. 示例 1.3. 擴(kuò)展正則表達(dá)式 1.3.1. 概念 1.3.2. 示例 在進(jìn)行程序設(shè)計(jì)的過(guò)程中,用戶會(huì)不可避免地遇到處理某些文本的情況。有的時(shí)候,用戶還需要查找符合某些比較復(fù)雜規(guī)則的字符串。對(duì)于這些情況,如

    2024年03月17日
    瀏覽(22)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包