当前位置: 首页 > news >正文

网站建设外包服务管理情况凡科快图网页版

网站建设外包服务管理情况,凡科快图网页版,南宁关键词排名,网站建设 青海文章目录一、作用二、注解属性说明三、使用方式一、作用 主要是从定义的扫描路径中#xff0c;找出标识了需要装配的类自动装配到Spring的bean容器中。 简单的说就是 ComponentScan告诉Spring从哪里找到bean#xff0c;一旦指定了#xff0c;Spring就会将指定的包及其下级… 文章目录一、作用二、注解属性说明三、使用方式一、作用 主要是从定义的扫描路径中找出标识了需要装配的类自动装配到Spring的bean容器中。 简单的说就是 ComponentScan告诉Spring从哪里找到bean一旦指定了Spring就会将指定的包及其下级的包中寻找bean。 在SpringBoot项目中我们并没有显示的看到该注解但是仍然能扫描到bean呢 其实在创建SpringBoot项目中默认在启动类上添加了SpringBootApplication注解该注解中包含ComponentScan注解因此SpringBoot会自动帮我们扫描启动类所在的包。 二、注解属性说明 Retention(RetentionPolicy.RUNTIME) Target(ElementType.TYPE) Documented Repeatable(ComponentScans.class) public interface ComponentScan {/*** 对应的包扫描路径 可以是单个路径也可以是扫描的路径数组* return*/AliasFor(basePackages)String[] value() default {};/*** 和value一样是对应的包扫描路径 可以是单个路径也可以是扫描的路径数组* 如果为空则以ComponentScan注解的类所在的包为基本的扫描路径* return*/AliasFor(value)String[] basePackages() default {};/*** 指定具体的扫描的类* return*/Class?[] basePackageClasses() default {};/*** 对应的bean名称的生成器 默认的是BeanNameGenerator* return*/Class? extends BeanNameGenerator nameGenerator() default BeanNameGenerator.class;/*** 处理检测到的bean的scope范围*/Class? extends ScopeMetadataResolver scopeResolver() default AnnotationScopeMetadataResolver.class;/*** 是否为检测到的组件生成代理* Indicates whether proxies should be generated for detected components, which may be* necessary when using scopes in a proxy-style fashion.* pThe default is defer to the default behavior of the component scanner used to* execute the actual scan.* pNote that setting this attribute overrides any value set for {link #scopeResolver}.* see ClassPathBeanDefinitionScanner#setScopedProxyMode(ScopedProxyMode)*/ScopedProxyMode scopedProxy() default ScopedProxyMode.DEFAULT;/*** 控制符合组件检测条件的类文件 默认是包扫描下的 **/*.class* return*/String resourcePattern() default ClassPathScanningCandidateComponentProvider.DEFAULT_RESOURCE_PATTERN;/*** 是否对带有Component Repository Service Controller注解的类开启检测,默认是开启的* return*/boolean useDefaultFilters() default true;/*** 指定某些定义Filter满足条件的组件 FilterType有5种类型如* ANNOTATION, 注解类型 默认* ASSIGNABLE_TYPE,指定固定类* ASPECTJ ASPECTJ类型* REGEX,正则表达式* CUSTOM,自定义类型* return*/Filter[] includeFilters() default {};/*** 排除某些过来器扫描到的类* return*/Filter[] excludeFilters() default {};/*** 扫描到的类是都开启懒加载 默认是不开启的* return*/boolean lazyInit() default false; }三、使用方式 启动类 package com.springboottest;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan;SpringBootApplication public class SpringbootTestApplication {public static void main(String[] args) {SpringApplication.run(SpringbootTestApplication.class, args);} }启动类在 com.springboottest 包下那么Spring默认会自动扫描该包及其子包下的bean。 Student类包路径com.springtest非启动类所在的包下 package com.springtest;import lombok.Data; import org.springframework.stereotype.Component;Data Component public class Student {private String name;private String nickName; }如果想让Student类被Spring扫描到那么我们可在启动类中增加如下注解 package com.springboottest;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan;SpringBootApplication ComponentScan(basePackages {com.springtest, com.springboottest}) // ComponentScan(basePackages {com}) public class SpringbootTestApplication {public static void main(String[] args) {SpringApplication.run(SpringbootTestApplication.class, args);} }上面的代码我们可以看到ComponentScan注解中设置了两个包名com.springtest, com.springboottest这样设置是为了精确扫描范围当然我们也可以使用两个包名的共同前缀com。 注如果需要扫描的类在不同的包下最好是精确指定要扫描的包这样可以减少加载时间。
http://www.pierceye.com/news/737966/

相关文章:

  • 网站建设基础实训报告天津滨海新区地图全图
  • 兰西网站建设深圳58同城招聘网
  • 兰州网站建设程序烟台赶集网网站建设
  • 自己建立网站后怎么做淘客wordpress需要npv
  • 简单网站建设推荐wordpress主题ashley
  • 单页网站开发实例下载电商营销渠道有哪些
  • 沈阳科技网站首页东营市做网站
  • 网站移动端开发公司客户评价网站建设
  • 有没有做问卷还能赚钱的网站鲜花网站数据库建设
  • 二手房房产网站建设下载网站 源码
  • 做简单手机网站多少钱呀唐山哪里建轻轨和地铁
  • jsp是做网站后台的吗wordpress设置备份
  • 做网站一般使用什么算法织梦 导航网站 模板
  • 网站建设服务费合同如何解决网站只收录首页的一些办法
  • 用js做网站登录阿里巴巴运营岗位
  • 老渔哥网站建设公司重庆建设厂
  • 怎么建网站手机版松门建设规划局网站
  • wordpress网站破解整容医院网络建设公司
  • app如何推广深圳网络排名优化
  • 网站seo规范南昌it制作电商网站的公司
  • 深圳网站设计 工作室深圳品牌设计工作室
  • 手机网站静态动态wordpress注意
  • 什么网站没人做v5shop微分销系统
  • 做鞋子的网站品牌vi设计包括哪些
  • 做产品类的工作上什么网站好asp.net做的网站模板下载
  • 金融公司网站规划方案我司网站改版上线网站建设
  • 城乡与住房建设部网站首页深圳响应式设计企业网站
  • 做网站 带宽 多少钱做电影网站的服务器需要多大
  • 西安网站建设全包用手机制作游戏的软件
  • 哪个网站生鲜配送做的好drupal wordpress网站