spring注解驱动开发(一)
1、需要导入的spring框架的依赖
<dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>4.3.12.RELEASE</version></dependency>
2、@Configuration
设置类为配置类
3、AnnotationConfigApplicationContext
- 通过配置类获取上下文环境applicationContext
- 可以通过getBeanDefinitionNames()获得配置类中配置的各类Bean
- 也可以使用getBeanNamesForType()通过类型来获得bean的name(id)
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();for (String str : beanDefinitionNames) {System.out.println(str);}
4、@Bean
- 注册一个javaBean
- 默认用方法名作为Bean的id
- 使用AnnotationConfigApplicationContext的实例 通过getBean来获得这个Bean
@Configuration
@ComponentScan(value = "com.atguigu")
public class MainConfig {@Beanpublic Person person(){return new Person("lisi",20);}
}
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);Person bean = applicationContext.getBean(Person.class);System.out.println(bean);
5、@ComponentScan
为配置类开启组件扫描
- 放在配置类的上方,指定扫描的包路径如
@ComponentScan(value = "com.atguigu")
- 还可以使用excludeFilter来设置类扫描规则如包含、排除,excludeFilter需要设置为一个数组
排除
包含使用excludeFilter,并为其设置一个过滤数组,来指定需要过滤掉那些组件
@Configuration
@ComponentScan(value = "com.atguigu",excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes ={Controller.class,Service.class} )
})
public class MainConfig {@Beanpublic Person person(){return new Person("lisi",20);}
}
包含
包含使用includeFilter,包含里面需要设置使用默认规则为false
@Configuration
@ComponentScan(value = "com.atguigu",includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes ={Controller.class,Service.class} )},useDefaultFilters = false)
public class MainConfig {@Beanpublic Person person(){return new Person("lisi",20);}
}
还可以设置按给定类型过滤
@Configuration
@ComponentScan(value = "com.atguigu",includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes ={Controller.class,Service.class}),@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes ={BookService.class})
},useDefaultFilters = false)
public class MainConfig {@Beanpublic Person person(){return new Person("lisi",20);}
}
其他可以设置的过滤方式还可以有:
- 使用FilterType.ASPECTJ按照ASPECTJ表达式
- 使用FilterType.REGEX按照REGEX正则表达式
- 使用FilterType.CUSTOM按照自定义规则过滤(需要实现TypeFilter接口)
自定义过滤规则
public class MyTypeFilter implements TypeFilter {/*metadataReader:读取到的当前正在扫描的类的信息metadataReaderFactory:可以获取到其他任何类的信息*/@Overridepublic boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {//获取当前类的注解信息AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();//获取当前正在扫描的类的类信息ClassMetadata classMetadata = metadataReader.getClassMetadata();//获取当前类的资源(类的路径)Resource resource = metadataReader.getResource();String className = classMetadata.getClassName();System.out.println(resource);System.out.println(className);if(className.contains("er")){return true;}return false;}
}
设置自定义规则
@Configuration
@ComponentScan(value = "com.atguigu",includeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM,classes = {MyTypeFilter.class})
},useDefaultFilters = false)
public class MainConfig {@Beanpublic Person person(){return new Person("lisi",20);}
}
测试代码
@Testpublic void testbeans() {AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();for (String str : beanDefinitionNames) {System.out.println(str);}}
测试结果
测试规则打印内容
file [/Users/human/Desktop/Project/05SpringMVC/spring-annotation/target/classes/com/atguigu/bean/Person.class]
com.atguigu.bean.Person
file [/Users/human/Desktop/Project/05SpringMVC/spring-annotation/target/classes/com/atguigu/config/MyTypeFilter.class]
com.atguigu.config.MyTypeFilter
file [/Users/human/Desktop/Project/05SpringMVC/spring-annotation/target/classes/com/atguigu/controller/BookController.class]
com.atguigu.controller.BookController
file [/Users/human/Desktop/Project/05SpringMVC/spring-annotation/target/classes/com/atguigu/dao/BookDAO.class]
com.atguigu.dao.BookDAO
file [/Users/human/Desktop/Project/05SpringMVC/spring-annotation/target/classes/com/atguigu/service/BookService.class]
com.atguigu.service.BookService
file [/Users/human/Desktop/Project/05SpringMVC/spring-annotation/target/classes/com/atguigu/test/MainTest.class]
com.atguigu.test.MainTest
测试类打印过滤结果
org.springframework.context.annotation.internalConfigurationAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalRequiredAnnotationProcessor
org.springframework.context.event.internalEventListenerProcessor
org.springframework.context.event.internalEventListenerFactory
mainConfig
person
myTypeFilter
bookController
bookService
6、@Controller
将类配置为Controller类
7、@Service
将类配置为service类
8、@Repository
将类配置为dao操作的类
9、@Component
将类配置为通用类组件
10、@Scope
调整bean的作用域范围,默认单实例,可以修改为多实例
Bean是默认单实例的,通过指明prototype(多实例)和singleton(单实例)属性指明是否单实例
- prototype:多实例
- singleton:单实例
- request:同一次请求创建一个实例
- session:同一个session创建一个实例
@Configuration
@ComponentScan(value = "com.atguigu")
public class MainConfig {//Bean是默认单实例的,通过指明prototype(多实例)和singleton(单实例)属性指明是是否单实例//prototype:多实例//singleton:单实例//request:同一次请求创建一个实例//session:同一个session创建一个实例@Scope("prototype")@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}
}
测试
@Testpublic void testbeans() {AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);Object bean1 = applicationContext.getBean("person");Object bean2 = applicationContext.getBean("person");System.out.println(bean1==bean2);}
测试结果为false
11、@Lazy懒加载
实例默认在容器创建时立即加载
使用@Lazy后,当需要创建实例时才被加载
- 不使用懒加载
实体类构造函数
public Person(String name, Integer age) {System.out.println("给容器添加Person对象");this.name = name;this.age = age;}
测试代码
@Testpublic void testbeans() {AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);System.out.println("容器已创建完成");//没有获取类的代码,单实际上类的实例已经被加载进容器了}
测试结果
给容器添加Person对象
容器已创建完成
- 使用懒加载
@Configuration
@ComponentScan(value = "com.atguigu")
public class MainConfig {
// @Scope("prototype")@Lazy@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}
}
测试代码
@Testpublic void testbeans() {AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);System.out.println("容器已创建完成");Object bean1 = applicationContext.getBean("person");//这一句出现后才加载Person类}
测试结果
给容器添加Person对象
容器已创建完成
12、@Conditional
- 按一定条件注册bean,满足条件就给容器注册bean,否则不注入
- 要作为自定义条件,需要创建自定义condition类,并要实现Condition接口,并实现match方法
- conditional不仅可以标在方法上,还可以标记在类上
//判断是否是Linux系统的条件
//要作为自定义条件,要实现Condition接口,并实现match方法
//AnnotatedTypeMetadata:注释信息
public class LinuxCondition implements Condition {@Overridepublic boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {//判断linux洗洗ConfigurableListableBeanFactory beanFactory = conditionContext.getBeanFactory();//获取类加载器ClassLoader classLoader = conditionContext.getClassLoader();//获得当前环境信息Environment environment = conditionContext.getEnvironment();//获取到bean定义的注册类BeanDefinitionRegistry registry = conditionContext.getRegistry();String OSproperty = environment.getProperty("os.name");if (OSproperty.contains("Mac OS X")){return true;}return false;}
}
另一个自定义条件
public class WindowsCondition implements Condition {@Overridepublic boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {Environment environment = conditionContext.getEnvironment();//获取操作系统信息String OSproperty = environment.getProperty("os.name");if (OSproperty.contains("Window")){return true;}return false;}
}
配置类信息
@Configuration
@ComponentScan(value = "com.atguigu")
public class MainConfig {
// @Scope("prototype")@Lazy@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}@Conditional({WindowsCondition.class})@Bean("male")public Person personMale(){return new Person("lisi",33);}@Conditional({LinuxCondition.class})@Bean("female")public Person personFemale(){return new Person("wanger",23);}
}
测试类信息
@Testpublic void testBeans() {AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);//获取ioc容器的运行环境ConfigurableEnvironment environment=applicationContext.getEnvironment();//获取操作系统名称String property = environment.getProperty("os.name");System.out.println(property);String[] namesForType = applicationContext.getBeanNamesForType(Person.class);for (String name:namesForType) {System.out.println(name);}}
测试结果
Mac OS X
person
female
13、给IOC容器中注册组件的5种方法
- 包扫描+组件类上标注注解:(@Controller,@Service,@Repository,@Component)
- @Bean:导入第三方包的组件
- @Import:快速给容器导入一个组件
1)@Import(要导入到容器的组件),容器中就会自动注册这个逐渐,id默认是全类名
2)ImportSelector:返回需要导入的组件的全类名数组
4.使用ImportBeanDefinitionRegistrar
5.使用Spring提供的FactoryBean(工厂bean)注册组件
1)默认获得的是工厂bean调用getObject创建的对象
2)要获取工厂bean本身,需要给id前面加一个&标识
14、@Import 快速导入一个类
使用@Import快速为配置类导入一个bean类
可以同时导入多个bean类
需要再配置类上方书写
- 创建被导入的bean类
public class Color {
}
public class Red {
}
- 给配置类导入该类
@Configuration
@ComponentScan(value = "com.atguigu")
@Import({Color.class, Red.class})//在这里进行快速地导入,可以是数组形式
public class MainConfig {
// @Scope("prototype")@Lazy@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}@Conditional({WindowsCondition.class})@Bean("male")public Person personMale(){return new Person("lisi",33);}@Conditional({LinuxCondition.class})@Bean("female")public Person personFemale(){return new Person("wanger",23);}
}
测试类代码
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);@Testpublic void testImport(){printBeans(applicationContext);}private void printBeans(AnnotationConfigApplicationContext applicationContext){String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();for (String name:beanDefinitionNames) {System.out.println(name);}}
测试结果
org.springframework.context.annotation.internalConfigurationAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalRequiredAnnotationProcessor
org.springframework.context.event.internalEventListenerProcessor
org.springframework.context.event.internalEventListenerFactory
mainConfig
bookController
bookDAO
bookService
com.atguigu.bean.Color
com.atguigu.bean.Red
person
female
15、ImportSelector接口导入一个类
- ImportSelector:返回需要导入的组件的全类名数组
- 需要实现ImportSelector接口并改写selectImports方法
创建需要被导入的类
public class Blue {
}
public class Yellow {
}
创建自己的Import类
public class MyImportSelect implements ImportSelector {@Overridepublic String[] selectImports(AnnotationMetadata annotationMetadata) {//返回值是要导入到容器中的组件全类名//annotationMetadata:注解信息return new String[]{"com.atguigu.bean.Blue", "com.atguigu.bean.Yellow"};}
}
在配置类中设置@Import导入的自定义类选择器
注意:@Import({Color.class, Red.class,MyImportSelect.class})
@Configuration
@ComponentScan(value = "com.atguigu")
@Import({Color.class, Red.class,MyImportSelect.class})
public class MainConfig {
// @Scope("prototype")@Lazy@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}@Conditional({WindowsCondition.class})@Bean("male")public Person personMale(){return new Person("lisi",33);}@Conditional({LinuxCondition.class})@Bean("female")public Person personFemale(){return new Person("wanger",23);}
}
测试代码
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);@Testpublic void testImport(){printBeans(applicationContext);}private void printBeans(AnnotationConfigApplicationContext applicationContext){String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();for (String name:beanDefinitionNames) {System.out.println(name);}}
测试结果
Color,Red,Blue,Yellow都有了
org.springframework.context.annotation.internalConfigurationAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalRequiredAnnotationProcessor
org.springframework.context.event.internalEventListenerProcessor
org.springframework.context.event.internalEventListenerFactory
mainConfig
bookController
bookDAO
bookService
com.atguigu.bean.Color
com.atguigu.bean.Red
com.atguigu.bean.Blue
com.atguigu.bean.Yellow
person
female
16、使用ImportBeanDefinitionRegistrar接口导入类
自定义导入的类定义,需要实现ImportBeanDefinitionRegistrar接口,并重写 registerBeanDefinitions方法
创建一个需要被注入的类
public class RainBow {
}
创建自定义的注册类信息类
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {//annotationMetadata:当前类的注解信息//beanDefinitionRegistry:beanDefinition注册类//把所有需要添加到容器中的bean,调用beanDefinitionRegistry.registerBeanDefinition手动注册类@Overridepublic void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {boolean red = beanDefinitionRegistry.containsBeanDefinition("com.atguigu.bean.Red");//判断定义中是否有红色boolean blue = beanDefinitionRegistry.containsBeanDefinition("com.atguigu.bean.Blue");//判断定义中是否有蓝色if(red && blue){//指定bean名RootBeanDefinition rainbowDefinition = new RootBeanDefinition(RainBow.class);//注册了一个bean,并指定了一个类名(别名)beanDefinitionRegistry.registerBeanDefinition("rainbow", rainbowDefinition);}}
}
在配置类中进行配置
注意:@Import({Color.class, Red.class,MyImportSelect.class,MyImportBeanDefinitionRegistrar.class})
@Configuration
@ComponentScan(value = "com.atguigu")
@Import({Color.class, Red.class,MyImportSelect.class,MyImportBeanDefinitionRegistrar.class})
public class MainConfig {
// @Scope("prototype")@Lazy@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}@Conditional({WindowsCondition.class})@Bean("male")public Person personMale(){return new Person("lisi",33);}@Conditional({LinuxCondition.class})@Bean("female")public Person personFemale(){return new Person("wanger",23);}
}
测试类
@Testpublic void testImport(){printBeans(applicationContext);}private void printBeans(AnnotationConfigApplicationContext applicationContext){String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();for (String name:beanDefinitionNames) {System.out.println(name);}}
测试结果
显示了rainbow
org.springframework.context.annotation.internalConfigurationAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalRequiredAnnotationProcessor
org.springframework.context.event.internalEventListenerProcessor
org.springframework.context.event.internalEventListenerFactory
mainConfig
bookController
bookDAO
bookService
com.atguigu.bean.Color
com.atguigu.bean.Red
com.atguigu.bean.Blue
com.atguigu.bean.Yellow
person
female
rainbow
17、使用FactoryBean接口导入类
创建自定义工厂类,实现FactoryBean接口,并改写一下方法
getObject() //返回工厂生产的类对象
getObjectType()//返回工厂生产的类类型
isSingleton() //返回单例
创建自定义工厂类
这里实现FactoryBean接口,实现三个方法,注意泛型中使用Color类
public class ColorFactory implements FactoryBean<Color> {//返回一个Color对象,这个对象会添加到容器中@Overridepublic Color getObject() throws Exception {System.out.println("color factory generate a instance");return new Color();}@Overridepublic Class<?> getObjectType() {return Color.class;}@Overridepublic boolean isSingleton() {//true:返回单例,在容器中保存一份//false:返回多份类实例,每次获取工厂bean都会创建一个新的对象return false;}
}
在配置类中定义这个类组件
注意:
@Bean
public ColorFactory colorFactoryBean(){
return new ColorFactory();
}
}
@Configuration
@ComponentScan(value = "com.atguigu")
@Import({Color.class, Red.class,MyImportSelect.class,MyImportBeanDefinitionRegistrar.class})
public class MainConfig {
// @Scope("prototype")@Lazy@Bean("person")//指定bean的自定义idpublic Person person(){return new Person("张三",20);}@Conditional({WindowsCondition.class})@Bean("male")public Person personMale(){return new Person("lisi",33);}@Conditional({LinuxCondition.class})@Bean("female")public Person personFemale(){return new Person("wanger",23);}@Beanpublic ColorFactory colorFactoryBean(){return new ColorFactory();}
}
测试类
public class MainTest {AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);@Testpublic void testImport(){printBeans(applicationContext);//工厂bean获取的是调用的是getObject创建的对象(Color类)Object bean1 = applicationContext.getBean("colorFactoryBean");Object bean2 = applicationContext.getBean("colorFactoryBean");System.out.println(bean1);System.out.println(bean2.getClass());//class com.atguigu.bean.ColorSystem.out.println(bean1==bean2);}private void printBeans(AnnotationConfigApplicationContext applicationContext){String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();for (String name:beanDefinitionNames) {System.out.println(name);}}
测试结果
org.springframework.context.annotation.internalConfigurationAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalRequiredAnnotationProcessor
org.springframework.context.event.internalEventListenerProcessor
org.springframework.context.event.internalEventListenerFactory
mainConfig
bookController
bookDAO
bookService
com.atguigu.bean.Color
com.atguigu.bean.Red
com.atguigu.bean.Blue
com.atguigu.bean.Yellow
person
female
colorFactoryBean
rainbow
color factory generate a instance
color factory generate a instance
com.atguigu.bean.Color@79c97cb
class com.atguigu.bean.Color
false相关文章:
spring注解驱动开发(一)
1、需要导入的spring框架的依赖 <dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>4.3.12.RELEASE</version></dependency>2、Configuration 设置类为配置类 3、Annota…...
Vue3搭建启动
Vue3搭建&启动 一、创建项目二、启动项目三、配置项目1、添加编辑器配置文件2、配置别名3、处理sass/scss4、处理tsx(不用的话可以不处理) 四、添加Eslint 一、创建项目 npm create vite 1.project-name 输入项目名vue3-vite 2.select a framework 选择框架 3.select a var…...
阻塞队列(模拟实现)
概念 阻塞队列是带有阻塞功能的队列 特性 当队列满的时候,继续入队列,就会出现阻塞,阻塞到其他线程从队列中取走元素为止 当队列空的时候,继续出队列,也会发生阻塞,阻塞到其他线程往队列中添加元素为止 特…...
VScode中python的相对路径与绝对路径 FileNotFoundError: [Errno 2] No such file or directory
VScode中,python里的相对路径是相对于当前工作目录来定位的,而当前的工作目录在VScode中下方的终端窗口会有提示: 说明此时的工作目录并非当前python文件所在的目录,而是C:\Users\xxxxx(你的用户名)。因此,使用VScode…...
Unity XML2——C#读写XML
一、XML 文件的存放位置 (一)只读不写的 XML 放在 Resouces 或者 StreamingAssets 文件夹下,详见 Unity基础3——Resources资源动态加载_weixin_53163894的博客-CSDN博客。 (二)动态存储的 XML 放在 Applica…...
带wiringPi库的交叉编译 ---宿主机x86Ubuntu,目标机ARMv8 aarch64(香橙派)
带wiringPi库的交叉编译如何进行 先交叉编译wiringPi库,编译出的库适合香橙派,这时候交叉编译可执行程序的平台和链接库的格式也是正确的,然后通过-I和-L来指定链接的wiringPi库的头文件和库的位置,但是现在还没有学习过…...
数据仓库基础知识
什么是数据仓库? 数仓,DataWarehouse,是一个 面向主题的、集成的、稳定的、与时间相关的 数据集合。 而这个数据集合的建立,是为了支持管理者的决策过程。 也就是说,我们通过建设数仓,为业务中的流程改进、…...
M 芯片的 macos 系统安装虚拟机 centos7 网络配置
centos 安装之前把网络配置配好或者是把网线插好 第一步找到这个 第二步打开网络适配器 选择图中所指位置 设置好之后 开机启动 centos 第三步 开机以后 编写网卡文件保存 重启网卡就可以了,如果重启网卡不管用,则重启虚拟机即可 “ ifcfg-ens160 ” 这…...
AcWing 3708. 求矩阵的鞍点
输入样例: 3 4 1 2 3 4 1 2 3 4 1 2 3 4输出样例: 1 4 4 2 4 4 3 4 4 #include<bits/stdc.h> using namespace std; const int N1010; int n,m,a[N][N],x[N],y[N],flag1; int main(){scanf("%d%d",&n,&m);for(int i1;i<n;i…...
web前端开发工程师的具体职责范本(合集)
web前端开发工程师的具体职责范本1 职责: 1.负责web前端架构的搭建,核心业务功能开发和核心代码编写。 2.配合产品经理,实现产品UI和交互方面的需求,持续界面优化,提升用户体验。 3.参与相关业务需求变更评审。 4.…...
从源程序到可执行文件的四个过程
从源程序到可执行文件的四个过程 预处理编译汇编链接 程序要运行起来,必须要经过四个步骤:预处理、编译、汇编和链接,如下图所示: -E选项:提示编译器执行完预处理就停下来,后边的编译、汇编、链接就先不执…...
C++部署学习
gcc -E src/main.c -o src/main.i gcc -S src/main.c -o src/main.s gcc -C src/main.c -o src/main.o gcc src/main.c -o exec ./exec...
linux下lazarus开发ide里 BGRAControls控件库comboBox示例
下载开发工具 ftp://ftp.freepascal.org/pub/lazarus/releases/Lazarus%20Linux%20amd64%20DEB/Lazarus%202.2.6/https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%202.2.6/ sourceforge下载可能比较慢,选择 下载有问题&…...
Redis学习路线(9)—— Redis的场景使用
默认做好了其它的前提,只专注于Redis使用 一、短信登录 在没有Redis数据库时,我们会基于Session实现登录(利用令牌进行授权),是怎么实现的呢? (一)基于Session的短信登录功能 1、…...
糟了,数据库主从延迟了!
前言 在实际的生产环境中,由单台MySQL作为独立的数据库是完全不能满足实际需求的,无论是在安全性,高可用性以及高并发等各个方面 因此,一般来说都是通过集群主从复制(Master-Slave)的方式来同步数据&…...
VUE,子组件给父组件传递参数,props 自定义属性,ref
<template><div><!-- 子传父 --><!-- 通过父组件给子组件传递函数类型的props实现:子给父传递数据 --><AA :getAAname"getAAname"/><h1>AA:{{aaname}}</h1><!-- 通过父组件给子组件绑定一个自定…...
【Oracle系列】- Oracle数据迁移
【Oracle系列】- Oracle数据迁移 文章目录 【Oracle系列】- Oracle数据迁移一、概述二、数据迁移方案三、模拟迁移方案四、迁移步骤五、迁移方案及其实施细则5.1 exp/imp逻辑备份与恢复5.2 Storage存储迁移5.3 利用data guard迁移 一、概述 最近在做公司软件系统盘点时&#x…...
Linux环境安装MySQL(详细教程)
1、下载MySQL MySQL官网:MySQLhttps://www.mysql.com/ 下载社区版(免费,但不提供技术支持) 简单说明一下rpm和tar包的区别: tar 只是一种压缩文件格式,所以,它只是把文件压缩打包 rpm…...
23. Mysql中的排序规则
文章目录 Mysql中的排序规则1. 数据库默认的排序规则2. 查看表的排序规则2.1 查看表排序规则2.2 查看字段排序规则 3.修改排序规则3.1 修改库3.2 修改表3.3 修改字段 Mysql中的排序规则 1. 数据库默认的排序规则 mysql8的默认排序方式是 utf8mb4_0900_ai_ci mysql5的默认排序…...
MongoDB 基础学习记录
MongoDB 基础 mongoDB 是由 C语言编写,基于分布式文件存储的开源数据库系统,是一个 nosql 数据库. 在高负载的情况下,添加更多的节点,保证服务器性能,MongoDB 旨在为 web 引用提供可扩展的高性能存储解决方案,将数据存储为给文档, 数据结构由键值(key,value)对组成,MongoDB 文…...
QKeyMapper:Windows终极按键映射工具,无需重启立即生效
QKeyMapper:Windows终极按键映射工具,无需重启立即生效 【免费下载链接】QKeyMapper [按键映射工具] QKeyMapper,Qt开发Win10&Win11可用,不修改注册表、不需重新启动系统,可立即生效和停止,新增虚拟游戏…...
矿井排水系统直接关系到煤矿安全生产,今天咱们掰开揉碎了聊聊西门子S7-200 PLC控制三台水泵的实战经验。老规矩,先上干货再说原理
基于西门子PLC的煤矿排水系统控制,内容包括 [1]S7-200 PLC程序[2]MCGS6.2组态画面[3]电气图纸精品文档 共有3台水泵进行矿井排水,分别为1号水泵,2号水泵,3号水泵 其中1号,2号水泵是工作水泵,3号水泵是备用水…...
忍者像素绘卷惊艳案例:生成支持CSS Sprite切片的像素角色动作序列图
忍者像素绘卷惊艳案例:生成支持CSS Sprite切片的像素角色动作序列图 1. 像素艺术的新纪元 在游戏开发领域,像素艺术始终保持着独特的魅力。忍者像素绘卷作为一款基于Z-Image-Turbo深度优化的图像生成工具,为开发者带来了革命性的解决方案。…...
Graphormer部署案例:中小企业AI药物研发团队低成本GPU算力部署方案
Graphormer部署案例:中小企业AI药物研发团队低成本GPU算力部署方案 1. 项目背景与价值 在药物研发领域,分子属性预测是核心环节之一。传统实验方法成本高昂且周期漫长,而Graphormer作为基于纯Transformer架构的图神经网络,为这一…...
Python打包神器大PK:Nuitka vs PyInstaller,谁才是你的菜?(附实测数据)
Python打包工具深度评测:Nuitka与PyInstaller的终极对决 当开发者需要将Python项目分发给没有Python环境的用户时,打包工具的选择往往成为关键决策。本文将深入分析两大主流工具Nuitka和PyInstaller在多个维度的表现,帮助开发者根据项目需求做…...
AutoHotkey脚本编译指南:3步将.ahk文件转为独立可执行程序
AutoHotkey脚本编译指南:3步将.ahk文件转为独立可执行程序 【免费下载链接】Ahk2Exe Official AutoHotkey script compiler - written itself in AutoHotkey 项目地址: https://gitcode.com/gh_mirrors/ah/Ahk2Exe 你是否曾想过将精心编写的AutoHotkey自动化…...
避开深沟槽工艺的“坑”:从DLTS数据到TCAD仿真的硅光电二极管陷阱态优化实战
硅光电二极管陷阱态优化的工程实践:从DLTS表征到TCAD仿真 在半导体制造领域,深沟槽隔离(DTI)工艺虽然能有效解决器件间的串扰问题,但其引入的界面陷阱态却成为光电二极管性能提升的"隐形杀手"。工艺工程师们…...
从零到一:LRFormer (TPAMI 2025) 实战部署与避坑指南
1. 为什么选择LRFormer? 最近在复现TPAMI 2025上的LRFormer模型时,我发现这个基于局部-全局关系建模的视觉Transformer确实有不少亮点。相比传统CNN模型,它在处理长距离依赖关系时表现更出色,特别是在细粒度图像分类任务上&#x…...
从特效 SDK 到 AI 动效平台:Neon Vibe Motion 的技术演进之路
多媒体中台在 B 站主要负责剪辑、拍摄、直播等业务场景的动效渲染,开发维护的 SDK 在后文统一称为特效 SDK。 传统的视频特效生产一般分三条链路: 三条链路存在一个困境:效果丰富度、实时可交互、生产效率,三者不可兼得。 那么能…...
VBA循环到底用For、Do While还是Do Until?看完这篇别再傻傻分不清
VBA循环结构深度解析:如何精准选择For、Do While与Do Until? 刚接触VBA时,看到各种循环结构总让人眼花缭乱——For循环、For Each、Do While、Do Until...它们看起来都能完成相似的任务,但实际编码中选错循环类型,轻则…...
