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

大连flash网站wordpress变英文

大连flash网站,wordpress变英文,wordpress ssl部署,wordpress 爱情模板下载地址自动装配 ComponentScan 用于配置Spring需要扫描的被组件注解注释的类所在的包。 Component 用于标注一个普通的组件类#xff0c;它没有明确的业务范围#xff0c;只是通知Spring被此注解的类需要被纳入到Spring Bean容器中并进行管理。 Autowired Autowired用于自动装配…自动装配 ComponentScan 用于配置Spring需要扫描的被组件注解注释的类所在的包。 Component 用于标注一个普通的组件类它没有明确的业务范围只是通知Spring被此注解的类需要被纳入到Spring Bean容器中并进行管理。 Autowired Autowired用于自动装配对于接口的实现类可以使用该注解消除get和set方法。 声明一个接口 public interface UserService { void readyTest(String var); } 单个实现类 新建一个类实现该接口 import org.springframework.stereotype.Service; Service public class UserServiceImpl implements UserService{ Override public void readyTest(String var) { System.out.println(方法被调用收到参数var); } } 使用Autowired注解实现属性的自动装配 SpringBootTest class TestApplicationTests { // 属性自动装配可以省略get和set方法 // 此处的属性名称可以任意自定义都会去找 UserService 接口的唯一实现类 Autowired UserService userServiceImpl; Test void contextLoads() { userServiceImpl.readyTest(Autowired); } } 多个实现类 我们新建一个实现类 import org.springframework.stereotype.Service; Service public class UserServiceNewImpl implements UserService{ Override public void readyTest(String var) { System.out.println(新方法被调用收到参数var); } } 当有多个实现类的情况下会报错无法自动装配。存在多个 UserService 类型的 Bean。 idea会自动识别此错误。 此时需要显式指定实现类 SpringBootTest class TestApplicationTests { Autowired UserService userServiceNewImpl;// 参数名称为类名 Test void contextLoads() { userServiceNewImpl.readyTest(Autowired); } } 或者配合Qualifier注解使用 SpringBootTest class TestApplicationTests { Autowired Qualifier(userServiceNewImpl) // 指定实现类 UserService userService; Test void contextLoads() { userService.readyTest(Autowired); } } Resource Resource 和 Autowired 一样是用来实现依赖注入的。 声明一个接口 public interface UserService { void readyTest(String var); } 单个实现类 新建一个类实现该接口 import org.springframework.stereotype.Service; Service public class UserServiceImpl implements UserService{ Override public void readyTest(String var) { System.out.println(方法被调用收到参数var); } } 使用Resource 注解实现属性的自动装配 SpringBootTest class TestApplicationTests { Resource UserService userService; Test void contextLoads() { userService.readyTest(Resource); } } 当单个实现类对应不同的bean时也可以使用name属性指定具体的bean SpringBootTest class TestApplicationTests { Resource(namestudent) private SayInterface student; Resource(nameteacher) private SayInterface teacher; Test void contextLoads() { student.say(); teacher.say(); } } Configuration public class HumanConfig { Bean(name student,initMethod init) public Human getStudent() { Human student new Human(); student.setName(Teacher); return student; } Bean(name teacher,destroyMethod destroy) public Human getTeacher() { Human teacher new Human(); teacher.setName(Student); return teacher; } } 多个实现类 我们新建一个实现类 import org.springframework.stereotype.Service; Service public class UserServiceNewImpl implements UserService{ Override public void readyTest(String var) { System.out.println(新方法被调用收到参数var); } } 当有多个实现类的情况下会报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 需要区分的是idea不会自动识别此错误在运行时才会报错。 解决方法就是手动指定Resource的name属性 SpringBootTest class TestApplicationTests { Resource(name userServiceNewImpl) UserService userService; Test void contextLoads() { userService.readyTest(Resource); } } Configuration Configuration用于定义配置类可替换xml配置文件被注解的类内部包含有一个或多个被Bean注解的方法这些方法将会被AnnotationConfigApplicationContext或AnnotationConfigWebApplicationContext类进行扫描并用于构建bean定义初始化Spring容器。 简单来说就是初始化bean所对应的对象提供默认属性。 Configuration public class HumanConfig { Bean(name student,initMethod init) public Human getStudent() { Human student new Human(); student.setName(Teacher); return student; } Bean(name teacher,destroyMethod destroy) public Human getTeacher() { Human teacher new Human(); teacher.setName(Student); return teacher; } } ConditionalOnWebApplication 只有当spring为web服务时才使注解生效 AutoConfigureAfter 在加载配置类之后再加载当前类 ConditionalOnProperty 控制配置类是否生效 name 配置项的名字 havingValue 与配置的值对比 matchIfMissing 未配置属性时的匹配方式 Bean 方法级别上的注解产生一个被IOC容器所管理的bean。bean可以理解为一个豆子一个对象。 创建一个类 import lombok.Data; Data public class Human implements SayInterface { private String name; Override public void say() { System.out.println(Hello name); } public void init() { System.out.println(name init); } public void destroy() { System.out.println(name destroy); } } 创建一个配置类 Configuration public class HumanConfig { // 默认bean的名称和方法名相同 // 使用name定义bean的名称 // initMethod声明周期创建后执行 Bean(name student,initMethod init) public Human getStudent() { Human student new Human(); student.setName(Teacher); return student; }
http://www.huolong8.cn/news/323993/

相关文章:

  • 网站开发计入会计 什么科目营销型网站如何策划
  • 东营网站设计公司建筑门户网站
  • 网站的在线支付模块怎么做企业所得税优惠政策2020
  • 坪山网站建设行情做网站除了域名还要买什么
  • 免费资料网站网址下载视频网站开发php
  • 什么是网站建设技术react 网站开发
  • 校园淘宝店网站开发百度灰色关键词代发
  • 深圳外贸建站网络推广公司做爰全程的网站
  • 如何做网站连接手机app ui设计
  • 免费建立网站教程php作品源代码免费下载
  • 如何做网站的营销高端网页制作公司
  • 美仑-专门做服装的网站餐饮网站开发
  • 做网站的手机软件济南企业网站搭建
  • 专业做网站+上海建设制作网站
  • 做网站公司 备案在线做头像网站
  • 常德营销型网站建设小白如何建网站
  • 图片网站如何优化wordpress导入模板之后
  • 男女怎样做那个视频网站黄岗住房和城乡建设厅官方网站
  • 海口网站建设哪个好薇郑州企业网络推广
  • 渭南市住建设局网站司法局网站开发方案
  • 网站免费建站厂商定制深圳企业网站制作公司查询
  • 五金公司网站模板门户网站是指提供什么的网站
  • wordpress做企业展示站动漫设计就业率高吗
  • 虾皮购物网站怎么做php做网站需要注意什么
  • 莆田有交做外贸网站的没如何注册公司支付宝账户
  • 怎样用虚拟主机建网站天元网络
  • 城乡建设学校官方网站响应式网站框架
  • php做网站要多久一个网站空间可以做多少个网站
  • 纯手工建网站珠海网络推广公司
  • 修改网站需要什么手机端网站优化排名seo推广