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

江苏省交通厅门户网站建设管理办法做的网站怎么让百度收录

江苏省交通厅门户网站建设管理办法,做的网站怎么让百度收录,wordpress与微信公众号,读图机 东莞网站建设目录 1、Bean对象常用注解介绍 2、注解示例说明 1、Bean对象常用注解介绍 Component 通用类组件注解#xff0c;该类被注解#xff0c;IOC容器启动时实例化此类对象Controller 注解控制器类Service 注解业务逻辑类Respository 注解和数据库操作的类#xff0c;如DAO类Reso…目录 1、Bean对象常用注解介绍 2、注解示例说明 1、Bean对象常用注解介绍 Component 通用类组件注解该类被注解IOC容器启动时实例化此类对象Controller 注解控制器类Service 注解业务逻辑类Respository 注解和数据库操作的类如DAO类Resource 装配注解优先按名称装配如果名称匹配不上则按照类型匹配Autowired 装配注解按类型装配Spring 内置Inject 装配注解按类型装配JSR-330标准PostConstruct 方法注解功能参考xml文件中的init-method在实例化对象后自动执行Scope Bean属性注解功能参考xml文件中的Scope属性非WEB环境有多例和单例两种注解不写value或者不写此注解的情况下默认是单例Value 属性注解为Bean对象注入静态数据通常属性注入的值来自某个配置文件 2、注解示例说明 IOC容器注解方式配置Bean需要如下步骤 1、applicationContext.xml加入扫描的包此包项下的类被IOC容器扫描如有注解则实例化对象 !-- 扫描注解包--context:component-scan base-packagecom.text/!-- 加载配置文件 --context:property-placeholder locationclasspath:config.properties/ 配置文件config.properties示例jdbc连接                 jdbc.urljdbc:mysql://xxx.xxx.xxx.xxx:3306/xxx 2、配置Bean注解 package com.text.dao.impl; import com.text.dao.StudentDao; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; Repository Scope(prototype) //多例只是程序模拟实际项目上大部分是单例 public class StudentDaoImpl implements StudentDao {Value(${jdbc.url})private String url;public String getUrl() {return url;}public void setUrl(String url) {this.url url;} }package com.text.service.impl; import com.text.dao.StudentDao; import com.text.service.StudentService; import org.springframework.stereotype.Service; import javax.annotation.Resource; Service public class StudentServiceImpl implements StudentService {/*** Resource 注解后先从容器中找bean名称studentDao的对象没找到系统中实例对象名称是studentDaoImpl* 再通过类型StudentDao寻找找到studentDaoImpl注入到studentServiceImpl对象中* 由于studentDao是私有属性IOC容器会通过反射技术将studentDao改为puclic属性修改modifier值* 然后赋值赋值后再次将studentDao设置私有属性此种方式和xml中的property的方式不同property的方式是通过* 反射调用SetStudentDao方法实现注入*/Resourceprivate StudentDao studentDao;public StudentDao getStudentDao() {return studentDao;}public void setStudentDao(StudentDao studentDao) {this.studentDao studentDao;} }测试类 package com.text.entity;import com.text.dao.StudentDao; import com.text.dao.impl.StudentDaoImpl; import com.text.service.impl.StudentServiceImpl; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class Test {public static void main(String[] args) {String configLocation classpath:applicationContext.xml;ApplicationContext context new ClassPathXmlApplicationContext(configLocation);System.out.println(IOC容器完成初始化);String[] beanDefinitionNames context.getBeanDefinitionNames();for(String beanDefinitionName:beanDefinitionNames) {System.out.println(beanDefinitionName);//studentDaoImpl studentServiceImpl}StudentDao studentDao1 context.getBean(studentDaoImpl, StudentDao.class);StudentServiceImpl studentService context.getBean(studentServiceImpl, StudentServiceImpl.class);StudentDao studentDao2 studentService.getStudentDao();System.out.println(studentDao1 studentDao2);//falsestudentDaoImpl scope多例StudentDaoImpl studentDao3 (StudentDaoImpl)studentService.getStudentDao();System.out.println(studentDao3.getUrl());//jdbc:mysql://xxx.xxx.xxx.xxx:3306/xxx} }特别说明 Resource 注解StudentServiceImpl 后先从容器中找bean名称studentDao的对象没找到系统中实例对象名称是studentDaoImpl再通过类型StudentDao寻找找到studentDaoImpl注入studentServiceImpl对象的studentDao属性中由于studentDao是私有属性IOC容器会通过反射技术将studentDao改为puclic属性修改modifier值然后赋值赋值后再次studentDao设置私有属性此种方式和xml中的property的方式不同property的方式是通过反射调用SetStudentDao方法
http://www.w-s-a.com/news/973035/

相关文章:

  • 关于怎么做网站网站site的收录数量要多远索引量
  • 传世网站建设阳光创信-网站建设首选品牌
  • 周口建设网站中国装修公司十大排名
  • wordpress自助发卡青浦网站优化
  • 南京建设银行公积金查询网站wordpress加载插件下载
  • 做网站怎么那么难网站的建设与管理的心得体会
  • 黄冈网站建设哪家快些网站规划与建设评分标准
  • 建站平台 绑定域名怎么在手机上做网站
  • 做电影网站违法吗莱芜 网站
  • 品牌咨询公司泉州seo不到首页不扣费
  • 做网站做一个什么主题的怎样搭建一个企业网站
  • 做设计的有什么网站桂林论坛网站有哪些
  • 做的网站不能放视频开发公司春联
  • 重庆装修房子可以提取公积金吗长沙优化官网公司
  • 做外贸的网站都有哪些带后台的html网站源码
  • 厦门百度快速优化排名手机系统优化工具
  • 宁波网站制作公司推荐公司建站多少钱
  • 网络营销薪酬公司温州网站优化定制
  • 橙色在网站中的应用淘宝客绑定网站备案号
  • 杭州视频网站建设成都设计院排行
  • 慈溪建设网站盘丝洞app破解无限盘币
  • 关于服装店网站建设的策划方案seo关键词优化软件官网
  • 丰台高端网站建设土巴兔装修贵吗
  • 宽屏网站mysqli pdo wordpress
  • 2022年没封网站直接进入赣州网吧
  • 河南省建设厅证件证件查询网站硬件开发是什么意思
  • tp5做企业网站宿迁房产网租房信息
  • php高级网站开发wordpress不能添加文章
  • 小学校园网站建设付费阅读下载网站开发
  • 如何做招聘网站网站建设中 敬请期待