SPRINGBOOT学习记录

2023-11-12

SPRINGBOOT

1 入门

1 .1 springBoot具体流程

1yaml 配置文件

2 自动装配

3集成web框架

4 集成数据库

5分布式开发 Dubbo(rpc) zookeeper

6 swagger 接口文档

7 任务调度

8 springSecurity :shiro

1.2 springCould

1 微服务

2 springcould入门

3 RestFul

4 eureka

5 Ribbon

feign

HyStrix

zuul 路由网关

SpringCloud config:git

1.3 什么是微服务

MVC三层 MVVM微服务架构

微服务:是一种架构风格 是一系列小服务的组合 可以通过http互通,把需要的功能调度组合。

2 搭建框架

2.1 idea创建springBoot项目

1直接创建
在这里插入图片描述

在这里插入图片描述

2 配置完成后创建controller测试

@RestController
public class Mycontroller {


    @RequestMapping("/hello")
    public String h1(){
        return "我要死了";
    }

}

3 打包成jar包

4 终端调用

java -jar bootpro-0.0.1-SNAPSHOT.jar

5 配置文件 properties

#更改项目端口号
server.port=8081


#自定义banner
spring.banner.location=banner.txt

3 自动装配原理

3.1 自动装配原理

核心的依赖都在父工程中,版本管理和资源过滤

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

我们在引入springboot依赖的时候不需要指定版本,因为父pom中有管理仓库

启动器:

<!--web依赖 tomcat web。xml dispatcherServlet-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

我们需要使用什么功能就引入什么启动器

可以在项目的pom中配置依赖的版本:

<properties>
        <java.version>1.8</java.version>
        <mysql.version>5.*.*</mysql.version>
    </properties>

20210419注:

3.2 主程序

//集成封装了springconfig注解 标注这个类是一个springboot应用
@SpringBootApplication
public class BootproApplication {

    public static void main(String[] args) {
        //通过反射加载类
        SpringApplication.run(BootproApplication.class, args)   }

}

主程序注解

@SpringBootConfiguration //sprng配置文件 就是一个configuration 代表当前类为spring的配置类

@EnableAutoConfiguration //自动装配
//注解扫描
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
      @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })

//@SpringBoootConfiguration下的注解:(说明该class是一个spring配置类)
@Configuration

//EnableAutoConfigurations下的注解:
@AutoConfigurationPackage //自动配置包
@Import(AutoConfigurationImportSelector.class)//导入选择器

//@AutoConfigurationPackage下的注解
@Import(AutoConfigurationPackages.Registrar.class)//利用registar给容器中批量导入组件


/**
 * {@link ImportBeanDefinitionRegistrar} to store the base package from the importing
 * configuration.
 */
static class Registrar implements ImportBeanDefinitionRegistrar, DeterminableImports {

   @Override
   public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
       //将指定的一个包下的所有组件导入进来 默认为主程序所在的包下
      register(registry, new PackageImports(metadata).getPackageNames().toArray(new String[0]));
   }

   @Override
   public Set<Object> determineImports(AnnotationMetadata metadata) {
      return Collections.singleton(new PackageImports(metadata));
   }

}

(AutoConfigurationImportSelector.class 给容器导入组件

在这里插入图片描述

上图 获取所有的候选配置类

每个autoconfiguration(配置类)类 对应一个properties类 通过yaml或properties给具体属性赋值 被调用的autoconfig类会通过@Bean 注解生成程序运行所需的对象交给spring ioc容器管理(生成一个template对象)

在这里插入图片描述

List<String> loadFactoryNames(Class<?> factoryType, @Nullable ClassLoader classLoader) //这个方法得到所有的组件 从meta-info 下加载文件
    

在这里插入图片描述

​ 从spring.factories中读取配置(需要加载的类)
在这里插入图片描述

读取完全部配置 最后按照条件装备规则按需开启 例: 下图类上有注解 当容器中有advice时才加载进容器中 当添加了aop依赖后才能将其加进去
在这里插入图片描述

主程序运行过程

SpringApplication

1 判断应用的类是普通项目还是web项目

2 加载所有可用的初始化器 设置到initializers中

3 找出所有的应用程序监听器,设置到listener中

5 推断设置main方法的定义类 ,找到运行的主类

注:

springBoot 自动扫描主程序所在的包以及其所有子包下的组件,若想修改则可:@SpringBootApplication(scanBasePackages=“com”)

1 springboot先加载所有的自动配置类

2 每个自动备注类按照条件生效

3 生效的配置类会向容器中注册组件

注解总结:
在这里插入图片描述

基础注解:

@configuration:

配置类

(proxyBeanMethods=true) 全增量(full)开发模式 严格准守spring约束 bean为单例模式;

= false (lite)不为单例模式 getBean时spring运行时不会做检查 增加效率。

@Configuration
public class MyConfig {

    @Bean("kenan")
    public Student getStudent(){
        return new Student(22,"柯南",1608);
    }
    @Bean("miao")
    public Pet getPet(){
        return  new Pet();
    }
}

@import:

@Import(user.class) 在容器中创建出user类型的组件 默认组件名为全类名(包+类名)

@conditional:

条件装配,满足condition则进行组件注入

@ImportResources:

导入spring配置文件:

@ImportResources(“classpath:**”)

@ConfigurationProperties:

配置绑定

@PropertySource

加载指定的属性文件(*.properties)到 Spring 的 Environment 中。可以配合 @Value 和
@ConfigurationProperties 使用。
@PropertySource 和 @Value
组合使用,可以将自定义属性文件中的属性变量值注入到当前类的使用@Value注解的成员变量中。
@PropertySource 和 @ConfigurationProperties
组合使用,可以将属性文件与一个Java类绑定,将属性文件中的变量值注入到该Java类的成员变量中


1 导入依赖:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>

2 类上加注解:

@ConfigurationProperties(prefix = "mypet")
public class Pet {
    private String species;
    private String name;
}

3 properties文件:

mypet.species="猫"
mypet.name="咪咪"

使用方式:

1: @Component + @ConfigurationProperties

2 @ConfigutationProperties +EnableConfigurationProperties

@EnableConfigurationProperties(HelloServiceProperties.class)

4 yaml

4.1 yaml语法

#yaml格式配置文件
server:
  port: 8081

  #对象
  student:
    name: 克南
    age: 22


    #对象行内写法
  person: {name: 克南, age: 18}


    #数组
  pets:
      - cat
      - dog
      - pig


  #行内写法
  animals: [cat, dog, pig]

4.2 yaml 属性赋值

可以将yaml中的值与bean一一对应,给bean注入值

<!--使用configProperties注解需导入这个依赖-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
</dependency>
@ConfigurationProperties(prefix = "person")
public class Person {

    private String name;
    private int age;
    private Map maps;
}
person:
  name: sama
   age: ${random.int}
  maps: {hobby: girl, like: game}

4.3 指定配置文件

使用指定的properties文件

@PropertySource("classpath:kenan.properties")
name=克南
public class Dog {

    @Value("${name}")
    private String name;

    private int age;
}

4.4 yaml占位符表达式

id: ${random.int}
id2: ${random.uuid}
say: ${dog.hello:hello}aa #判断式如果冒号前的dog.hello存在 则调用hello的值 否则使用:后面的值

4.5 yaml松散绑定

驼峰和分隔符转换

private String lastName;
person:
    last-name: sama

5 JSR303校验

在后端校验数据的格式

<!--开启后台数据校验-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
@Validated
public class Person {

    @Email(message = "邮箱格式错误")
    private String name;
    private int age;
    private Map maps;
}

default message [邮箱格式错误]; origin class path resource [application.yaml]:3:11

6 多环境配置

配置文件的四个位置

1 根目录下的config文件夹:

2 根目录下:

3 classpath下的config下:

4 classpath下:

优先级 1 》 2 》 3 》4

yaml多环境配置选择 (spring profiles active)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8yQL75kd-1627207396216)(K:\u\study\文档\image-boot原理图6)]
在这里插入图片描述

server:
    port: 8081
spring:
  profiles:
    active: test
---
server:
  port: 8082
spring:
  profiles: dev


---
server:
  port: 8083
spring:
  profiles: test

7 导入静态资源

WebMvcAutoConfiguration下的

EnableWebMvcConfiguration

public void addResourceHandlers(ResourceHandlerRegistry registry) {
    if (!this.resourceProperties.isAddMappings()) {
        logger.debug("Default resource handling disabled");
        return;
    }
    Duration cachePeriod = this.resourceProperties.getCache().getPeriod();
    CacheControl cacheControl = this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl();
    if (!registry.hasMappingForPattern("/webjars/**")) {
        customizeResourceHandlerRegistration(registry.addResourceHandler("/webjars/**")
                                             .addResourceLocations("classpath:/META-INF/resources/webjars/")
                                              .setCachePeriod(getSeconds(cachePeriod)).setCacheControl(cacheControl));
    }
    String staticPathPattern = this.mvcProperties.getStaticPathPattern();
    if (!registry.hasMappingForPattern(staticPathPattern)) {
        customizeResourceHandlerRegistration(registry.addResourceHandler(staticPathPattern)
                                             .addResourceLocations(getResourceLocations(this.resourceProperties.getStaticLocations()))
                                             .setCachePeriod(getSeconds(cachePeriod)).setCacheControl(cacheControl));
    }
}

什么是webjars

springboot使用webjars统一管理静态资源

使用依赖的方式来引入web常用的包库 如jquery 等

在这里插入图片描述

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.6.0</version>
</dependency>

1 访问静态资源的路径为 /webjars/**

在这里插入图片描述

2 访问静态资源的默认路径 /** 例如:/t1.txt 那么就会到/** 所对应的映射目录去寻找t1.txt

在这里插入图片描述

<script src="webjars/jquery/3.4.1/jquery.js"></script>
<--用webjar引用静态资源-->
/**
 * Path pattern used for static resources.
 */
private String staticPathPattern = "/**";
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/resources/",
      "classpath:/resources/", "classpath:/static/", "classpath:/public/" };

/**
 * Locations of static resources. Defaults to classpath:[/META-INF/resources/,
 * /resources/, /static/, /public/].
 */

一般 static 放图片 public放公共js resources 放上下传文件

三者优先级 r > s > p

3 在配置文件中自定义静态资源位置

spring:
  mvc:
    static-path-pattern: /mystaic/, classpath:/mystatic/

7.1 首页

private Resource getIndexHtml(String location) {
   return this.resourceLoader.getResource(location + "index.html");
}

故须在静态资源文件夹下新建index.html

8 thymeleaf

默认的配置类配置了前缀和后缀

@ConfigurationProperties(prefix = "spring.thymeleaf")
public class ThymeleafProperties {

   private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;

   public static final String DEFAULT_PREFIX = "classpath:/templates/";

   public static final String DEFAULT_SUFFIX = ".html";

8.1 开始

可以在yaml中关闭thymeleaf缓存

spirng.thymleaf.cache: false

1导入依赖

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
/*在template文件下的html只能通过controller访问
* 需要模板引擎的支持*/
@Controller
public class IndexController {
    @RequestMapping("/a")
    public String index(){
        return "index";
    }

}

2 导入约束 声明thymeleaf的命名空间

<html lang="en" xmlns:th="http://www.thymeleaf.org">

3 元素中使用th标签

<!--所有的元素都可被html接管-->
<div th:text="${msg}"></div>

8.2 基本语法

<!--所有的元素都可被html接管-->
<div th:text="${msg}"></div>
<!--非转义字符串 可输出html-->
<div th:utext="${msg}"></div>
<!--遍历 users是集合 user是单个元素-->
<h2 th:each="user:${users}" th:text="${user}"></h2>
<!--两个中括号 中间加元素-->
<h2 th:each="user:${users}">
    [[${user}]]
</h2>
//工具类 可以将数组转换为集合
model.addAttribute("users", Arrays.asList("kenan","sama"));
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
<link  th:href="@{/css/animate.css}" rel="stylesheet">
<link  th:href="@{/css/style.css}" rel="stylesheet">
<link  th:href="@{/css/login.css}" rel="stylesheet">
<script th:src="@{/js/jquery-3.4.1.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>

9 扩展MVC

9.1 扩展MVC

自定义视图解析器

//扩展mvc
@Configuration
public class MyMVC implements WebMvcConfigurer {




    @Bean
public MyViewResolver myViewResolver(){
    return new MyViewResolver();
}


    //自己配置的viewResolver
    class MyViewResolver implements ViewResolver{

        @Override
        public View resolveViewName(String viewName, Locale locale) throws Exception {
            return null;
        }
    }
}
//添加一个视图跳转页面 相当于手动配置controller
@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/user").setViewName("index");
}

9.2 拦截器

@Override
public void addInterceptors(InterceptorRegistry registry) {
    //添加拦截链接 和不拦截的拦截
    registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns();
}

10 整合数据库

10.1 springboot JDBC

1 设置参数

spring:
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/graduation_project?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong
    driver-class-name: com.mysql.cj.jdbc.Driver

2 使用spring提供的jdbctemplate操作数据库

@RestController
public class MyController {
    @Autowired
    JdbcTemplate template;
    @RequestMapping("/test")
    public List<Map<String, Object>> t1(){
        String sql = "select * from patients";
        List<Map<String, Object>> maps = template.queryForList(sql);
        return maps;
    }
}
@RequestMapping("update/{name}/{id}")
public String update(@PathVariable("name") String name,  @PathVariable("id") String id){
    String sql = "update patients set p_name = ? where p_id = ?";
    Object[] objects = new Object[2];
    objects[0] = name;
    objects[1] = id;
    template.update(sql,objects);
    return "ok";

}

10.2 整合druid数据源

1 导入maven依赖

com.alibaba druid 1.1.22

2 指定数据库type并配置druid属性

spring:
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/graduation_project?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
#   数据源其他配置
    initialSize: 5
    minIdle: 5
    maxActive: 20
    maxWait: 60000
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: SELECT 1 FROM DUAL
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
#   配置监控统计拦截的filters,stat监控界面sql统计,'wall'用于防火墙防御sql注入 log4j 日志文件
    filters: stat,wall,log4j
    maxPoolPreparedStatementPerConnectionSize: 20
    useGlobalDataSourceStat: true
    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500

3 创建druid配置文件使其生效虽然我们配置了druid连接池的其它属性,但是不会生效。因为默认是使用的java.sql.Datasource的类来获取属性的,有些属性datasource没有。如果我们想让配置生效,需要手动创建Druid的配置文件。

 //绑定druiddatasource参数
    @ConfigurationProperties("spring.datasource")
    @Bean
    public DataSource dataSource(){
        return new DruidDataSource();
    }
//配置后台监控 注册一个servlet
@Bean
public ServletRegistrationBean tatViewServlet() {
    ServletRegistrationBean<StatViewServlet> bean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*");
    //设置后台管理用户 和一些配置
    HashMap<String, String> map = new HashMap<>();
    map.put("loginUsername", "admin");
    map.put("loginPassword", "123456");

    //设置访问白名单
    map.put("allow", "localhost");


    bean.setInitParameters(map);
    return bean;

}

11 整合Mybatis

前情提要:

spring整合mybatis时可以使用MapperScannerConfigurer实现mapper的动态代理(省去了手动实现mapper类的步骤“mapperImpl”)在接口上也可以省去@Repository注解

<!--生成mapper代理类-->
<bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.zzuli.mapper"/>
</bean>
public interface StuMapper {

    List<Student> getStu();
}

@mapper注解
@mapper在springboot中使用 添加在mapper接口上 在编译后悔生成对应的接口实现类

@MapperScan

在springboot的启动类上添加使用 其所指定的包中的接口在编译后都会生成对应的实现类

11.1 入门

1 引入maven依赖

org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.3

2编写mapper

@Mapper
public interface PatientMapper {
    List<Patient> getPat();

    Patient getPatById(String id);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="zuli.kenan.boot_mybatis.mapper.PatientMapper">


    <select id="getPat" resultMap="patMap">
        select  * from patients
    </select>

    <!--结果集-->
    <resultMap id="patMap" type="zuli.kenan.boot_mybatis.pojo.Patient">
        <result property="id" column="p_id"/>
        <result property="name" column="p_name"/>
        <result property="password" column="password"/>
    </resultMap>
</mapper>
#整合mybatis
mybatis:
  type-aliases-package: zuli.kenan.boot_mybatis.pojo
  mapper-locations: classpath*:mapper/*.xml
@MapperScan("com.kenan.mybatisboot.mapper")

12 SpringSecurity

功能权限

访问权限

菜单权限

需要拦截器 过滤器 都是原生代码

12.1 框架搭建

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //链式调用 建造者模式
        //指定访问策略
        //首页对应的功能页只有对应权限的人才能访问
        //url后面跟参数 * 当参数和hasrole中的规则一致时,才能访问
        http.authorizeRequests().antMatchers("/").permitAll()
                .antMatchers("/level1/**").hasRole("vip1")
                .antMatchers("/level2/**").hasRole("vip2");

        //访问被拦截后会跳到登录面(自带的)he most basic configuration defaults to automatically generating a login page at
        //  * the URL "/login", redirecting to "/login?error" for authentication failure.
        http.formLogin();
    }

    //认证用户  给指定的用户指定相应的role 要设置密码编码不使用明文密码
    // enable in memory based authentication with a user named
    //  *     // &quot;user&quot; and &quot;admin&quot;
    //  *     .inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;).and()
    //  *           .withUser(&quot;admin&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;, &quot;ADMIN&quot;);
    //  * }
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder())
                .withUser("kenan").password("1234").roles("v1","v2")
                .and()
                .withUser("kenan").password("22").roles("v3");
    }
}

13 Shiro

);

    //访问被拦截后会跳到登录面(自带的)he most basic configuration defaults to automatically generating a login page at
    //  * the URL "/login", redirecting to "/login?error" for authentication failure.
    http.formLogin();
}

//认证用户  给指定的用户指定相应的role 要设置密码编码不使用明文密码
// enable in memory based authentication with a user named
//  *     // &quot;user&quot; and &quot;admin&quot;
//  *     .inMemoryAuthentication().withUser(&quot;user&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;).and()
//  *           .withUser(&quot;admin&quot;).password(&quot;password&quot;).roles(&quot;USER&quot;, &quot;ADMIN&quot;);
//  * }
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder())
            .withUser("kenan").password("1234").roles("v1","v2")
            .and()
            .withUser("kenan").password("22").roles("v3");
}

}


## 13 Shiro

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SPRINGBOOT学习记录 的相关文章

  • 扫雷小游戏最详细讲解【C语言】

    大家好 我是同学 森 一名计算机爱好者 今天让我们进入小游戏开发学习模式 若有错误 请多多指教 小主使用的是VS2019编译器 点赞 收藏 留言 都是我创作的最大的动力 目录 大家好 我是同学 森 一名计算机爱好者 今天让我们进入小游戏开发
  • Git GUI,Git Bash,Git CMD之间的区别

    Git CMD就像使用git命令的常规Windows命令提示一样 它允许您通过命令行使用所有Git功能 如果您已熟悉Windows cmd并且只能在Windows上工作 则非常有用 Git Bash在Windows上模拟bash环境 它允许
  • Mysql JDBC和事务(细致而易懂)

    提示 文章写完后 目录可以自动生成 如何生成可参考右边的帮助文档 目录 安装环境 一 JDBC 二 preparedstament和statement的区别 三 批量处理 四 事务提交控制 最后 安装环境 1 jdk17 2 MySQL8
  • Qt自定义类使用自定义含参信号与槽

    最近在自定义类中使用了信号来连接到MainWindow类中的槽函数 具体操作如下 要点一 继承QObject 在头文件中初始化自定义类MyThread1 这里由于继承的QThread已经继承了QObject 无需嵌套继承 故不必public
  • Flutter 凸起效果底部导航栏一

    大多app中都会带有底部导航栏 系统默认自带的导航条不够新颖 今天我们改造一下导航条 将中间的按钮起到凸起的效果 特别有的app 中间常用扫一扫功能 Flutter为我们提供了一个控件BottomNavigationBar 结合Bottom
  • Linux——(第九章)磁盘分区、挂载

    目录 一 Linux分区概述 1 原理介绍 2 硬盘说明 二 查看磁盘和分区 1 du查看文件和目录占用的磁盘空间 2 df查看磁盘空间使用情况 3 lsblk查看设备挂载情况 4 mount unmount 挂载 卸载 5 fdisk 分
  • 解决VS Code开发Python3语言自动补全功能

    https www cnblogs com yuer20180726 p 10942372 html 1 打开设置界面 2 使用快捷键组合 Ctrl Shift p 入setting 选中首选项的user setting模式设置界面 在打开
  • 华为OD机试真题 Java 实现【光伏场地建设规划】【2023Q1 100分】

    一 题目描述 祖国西北部有一片大片荒地 其中零星的分布着一些湖泊 保护区 矿区 整体上常年光照良好 但是也有一些地区光照不太好 某电力公司希望在这里建设多个光伏电站 生产清洁能源 对每平方公里的土地进行了发电评估 其中不能建设的区域发电量为
  • 求字符串最长公共前缀

    第一种方法 for循环第一个字符串 然后再for循环除了第一个字符串以外的其它字符串 比较其它字符串是否以某个字符串开头 从而找到公共前缀 function getCommonStr arr if arr Array isArray arr
  • 面向对象编程(概念)

    面向对象编程 概念 面向过程 面向对象 面向过程思想 1 步骤清晰简单 第一步做什么 第二步做什么 2 面对过程是和处理一些较为简单的题目 面向对象思想 1 物以类聚 分类的思维模式 思考问题首先会解决问题需要哪些分类 然后对这些分类进行单
  • 解决ImportError: No module named zlib问题

    今天在创建django工程时 报了这个错 其实前几天也遇见过当时是在装一个setuptools时 报了这个错误zlib not available按照网上的方法 装好之后重新编译自己的Python 结果没有反应 还是报错 zlib模块是用来
  • java elasticsearch_Java操作ElasticSearch

    java客户端连接到ElasticSearch服务器 创建maven工程 添加坐标 最好跟服务器elasticsearch一致 org elasticsearch client transport 6 2 4 net sf json lib
  • type和interface的区别

    type和interface都可以用来表示接口 但实际用的时候会有写差异 1 type和interface的相同点 都是用来定义对象或函数的形状 interface example name string age number interf
  • 修复Chrome浏览器下载速度慢的问题

    前言 本人使用Mac端进行操作 Win端操作大体基本相同 差别不大 放心食用 特色 操作简单 配套软件链接齐全 传送门 链接 https pan baidu com s 1vcCcPlHaUQmYrQldVM8UVQ pwd 0000 提取
  • 2023第十四届蓝桥杯 C/C++大学生A组省赛 满分题解

    写在前面 以下代码 目前均可通过民间OJ数据 dotcpp New Online Judge 两个OJ题目互补 能构成全集 可以到对应链接下搜题提交 感谢OJ对题目的支持 如果发现任何问题 包含但不限于算法思路出错 OJ数据弱算法实际超时
  • linux固件以及与驱动的区别

    硬件越来越复杂 硬件的许多功能使用了程序实现 与直接硬件实现相比 固件拥有处理复杂事物的灵活性和便于升级 维护等优点 固件 firmware 就是这样的一段在设备硬件自身中执行的程序 通过固件标准驱动程序才能实现特定机器的操作 如 光驱 刻
  • Android Studio 真机调试与虚拟机

    虚拟机调试 1 创建一个简单的hello world例子 支持C 2 SDK manager 根据个人需要选择安装 勾选并点击右下角apply即会自动安装 3 AVD manager 4 运行android程序 弹出选择设备框时有可能无法查
  • python字典中键不允许重复_Python 字典中的“键”不允许重复。 (1.0分)_学小易找答案...

    填空题 已知 x 1 2 3 那么表达式 not set x 100 set x 的值为 1 0分 判断题 列表可以作为字典的 键 1 0分 填空题 已知 x 为非空列表 那么表达式 x reverse list reversed x 的值
  • python自动化课程笔记(十三)单例模型、代码性能、抛出异常

    单例模型 重要 class Person object instance None is first True def new cls args kwargs 如果类属性 instance的值为None 创建一个对象 并赋值为这个对象的引用
  • 一个双非计算机学生的长远规划(考研篇)

    一个双非计算机学生的长远规划 考研篇 本文于2022 5 14 第一次更新 本文于2022 12 07 第二次更新 第二次更新内容 作者此次更新已经是大三了 经历了三段实习 马上去第三家 实习 发现学历真的是让我们实现阶级跨越的鸿沟 没有更

随机推荐

  • 【YAML 学习】

    YAML是 JSON 的超集 因此是一种用于指定分层配置数据的便捷格式 YAML YAML Ain t Markup Language 的递归首字母缩写词 是一种数据序列化语言 旨在实现人性化 并与现代编程语言一起处理常见的日常任务 YAM
  • vue 使用axios 出现跨域请求

    设置一个代理服务器 使用proxyTable配置地方 1 项目文件目录的conf文件夹下的index js build dev 都可设置为一致 dev env require dev env port 80 assetsSubDirecto
  • 实用小工具(数据集转换...)

    xml2yolo py import xml etree ElementTree as ET import pickle import os from os import listdir getcwd from os path import
  • 精选腾讯技术干货200+篇,云加社区全年沙龙PPT免费下载!

    2019年已经过去 小编为大家整理了这一年以来云加社区发布的 200多篇腾讯干货 点击文章标题即可跳转到原文 请速速收藏哦 看腾讯技术 腾讯成本优化黑科技 整机CPU利用率最高提升至90 腾讯科技升级1000天 团战 登月与烟囱革命 看一看
  • @RestController注解作用

    作用 Controller和 ResponseBody的集合 Controller Controller标识的类 该类代表控制器类 控制层 表现层 这里控制层里面的每个方法 都可以去调用 Service标识的类 业务逻辑层 Response
  • java锁杂谈

    关于java锁 内容蛮多的 这篇文章只谈一部分见解 所以取名为杂谈 没有大纲 等后面锁的体系建立起来后再整理一下 那么开始吧 Java 锁有哪些 各种各样 网传15种有余 这些锁的底层大多是AQS实现的 比如 ReentrantLock可重
  • 搜集Shader一些参数(为自己)

    Shader ConfigurableShaders Rendering Properties Header Stencil Stencil Stencil ID 0 255 Float 0 ReadMask ReadMask 0 255
  • PLC控制运料小车往返运动

    实验要求 1 实验控制电路应该具有控制回路的总控制 其功能是启动和停止控制电路 它可以使小车停站的位置行程开关处于压合的位置 脱离延迟控制往返时为启动状态 及零压保护电路功能 2 小车沿轨道自动往返运动时 小车在行程内的任何位置时都可以起动
  • c++实现创建一个cocos2d-x的场景类

    文件 http pan baidu com s 1ntlu14H createVSClass cpp 定义控制台应用程序的入口点 include stdafx h include
  • RocketMQ消费者端消息列队六种负载均衡算法分析

    在RocketMQ启动的时候会启动负载均衡线程 过程如下 DefaultMQPullConsumerImpl start mQClientFactory start 上面点进去 gt MQClientInstance start rebal
  • 区间调度1.找到移除区间的最小数量

    求出最多有几个互不相交的区间 则做法是按end升序排序 选择一个结束最早的x 然后把区间中与它冲突的全部删除 别的区间的start要大于这个区间的end 接着重复步骤直到堆中没有区间 不用堆只用数组的话可以用一个for循环遍历整个数组 记录
  • 火猴之arc以及gesturemanager的应用(firemonkey)

    效果 目标 1 向左滑动 环形进度条从0 100 2 向右滑动 环形进度条从100 0 思路 1 放置3个arc组件 rotationangle设置为270 stroke的thickness设为30 2 放置gesturemanager组件
  • [Windows] 在磁盘管理中,脱机选项不可选,无法将磁盘脱机

    1 在磁盘管理中遇到无法脱机磁盘的情况 脱机选项不可选 可能是由于将虚拟内存设置到该磁盘上导致的 2 进入电脑属性 gt 高级系统设置 gt 高级 gt 性能设置 gt 高级 gt 更改 3 取消在该磁盘上设置的虚拟内存 4 再进入磁盘管理
  • Qt 智能指针

    C 11 标准中的提供的智能指针 在 Qt 中也提供了类似的替代功能 并且比 C 11 标准中提供的功能还要强大 所以如果我们使用 Qt 作为基础库 Qt 智能指针包括 QSharedPointer QScopedPointer QScop
  • 【react】js表达式和js语句(代码)的区别

    何为表达式 一定注意区分 js语句 代码 与 js表达式 1 表达式 一个表达式会产生一个值 可以放在任何一个需要值的地方 下面这些都是表达式 1 a 2 a b 3 demo 1 4 arr map 5 function test 2 语
  • Tomcat载入配置

    错误出现原因 未配置环境变量
  • (N1盒子) Openwrt 下 docker 容器访问互联网故障排除

    环境 硬件 N1盒子 Openwrt版本 openwrt flippy 60 o 情况描述 先是跑了个运行php的docker容器 日志里报错信息为 cURL error 7 Failed to connect to 域名 port 端口号
  • 《基于Linux物联网综合项目》常见问题汇总fae

    关于该课程说明 1 本课程目标 通过web浏览器访问服务器 实现登录 注册 数据库操作 远程操控硬件 采集环境信息 远程监控 拍照 图片显示等功能 将单片机 linux html 摄像头 数据库等知识点融入到一个项目中 2 什么群体适合学习
  • 自然语言处理卷积神经网络c 代码,卷积神经网络CNN 在自然语言处理中的应用

    序言 CNN在文本分类中取得了不俗的结果 而运用在这里的卷积可以分为1d 2d甚至是3d的 我们知道 CNN一般用来做图像 图像是可以通过预处理 将每幅照片都处理成一样的size的 也就是height和width具有一样的像素值 然后用一个
  • SPRINGBOOT学习记录

    SPRINGBOOT 1 入门 1 1 springBoot具体流程 1yaml 配置文件 2 自动装配 3集成web框架 4 集成数据库 5分布式开发 Dubbo rpc zookeeper 6 swagger 接口文档 7 任务调度 8