org.springframework.stereotype
org.springframework.stereotype 1、@controller 控制器(注入服务)
2、@service 服务(注入dao)
3、@repository dao(实现dao访问)
4、@component (把普通pojo实例化到spring容器中,相当于配置文件中的<bean id="" class=""/>)
@Component,@Service,@Controller,@Repository注解的类,并把这些类纳入进spring容器中管理。
下面写这个是引入component的扫描组件
<context:component-scan base-package=”com.mmnc”> 其中base-package为需要扫描的包(含所有子包)
1、@Service用于标注业务层组件
2、@Controller用于标注控制层组件(如struts中的action)
3、@Repository用于标注数据访问组件,即DAO组件.
4、@Component泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。
@Service public class UserServiceImpl implements UserService { }
@Repository public class UserDaoImpl implements UserDao { } getBean的默认名称是类名(头字母小写),如果想自定义,可以@Service(“***”) 这样来指定,这种bean默认是单例的,如果想改变,可以使用@Service(“beanName”)
@Scope(“prototype”)来改变。可以使用以下方式指定初始化方法和销毁方法(方法名任意): @PostConstruct public void init() { }
org.springframework.stereotype的更多相关文章
- org.springframework.stereotype 注解
org.springframework.stereotype 1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访 ...
- org.springframework.stereotype.Service和com.alibaba.dubbo.config.annotation.Service两种service的区别
这两个Service,都可以在service类头上使用@Service的注解,于是我就写错了,查了半天才发现.他们的区别大概是这个样子的: org.springframework.stereotype ...
- Java-API-Package:org.springframework.stereotype
ylbtech-Java-API-Package:org.springframework.stereotype 1.返回顶部 1. @NonNullApi @NonNullFields Package ...
- Java-Class-@I:org.springframework.stereotype.Service
ylbtech-Java-Class-@I:org.springframework.stereotype.Service 1.返回顶部 2.返回顶部 1. package com.ylbtech. ...
- nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException
You should autowire interface AbstractManager instead of class MailManager. If you have different im ...
- SpringMVC(四):@RequestMapping结合org.springframework.web.filter.HiddenHttpMethodFilter实现REST请求
1)REST具体表现: --- /account/1 HTTP GET 获取id=1的account --- /account/1 HTTP DELETE 删除id=1的account ...
- spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available
我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.b ...
- springtest mapper注入失败问题解决 {@org.springframework.beans.factory.annotation.Autowired(required=true)}
花费了一下午都没有搜索到相关解决方案的原因,一是我使用的 UnsatisfiedDependencyException 这个比较上层的异常(在最前面)来进行搜索, 范围太广导致没有搜索到,而且即便是有 ...
- spring boot之org.springframework.boot.context.TypeExcludeFilter
曾经碰到过这样一种情况,想让某个使用了spring 注解的类不被spring扫描注入到spring bean池中,比如下面的类使用了@Component和@ConfigurationPropertie ...
随机推荐
- Nginx 核心配置-根目录root指令与别名alias指令实战案例
Nginx 核心配置-根目录root指令与别名alias指令实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.试验环境说明 1>.虚拟机环境说明 [root@nod ...
- 【JavaScript】BOM对象——Window对象&History对象&Location 对象
1.Window对象: 表示浏览器中打开的窗口 setInterval():它有一个返回值,主要是提供给 clearInterval 使用. setTimeout():它有一个返回值,主要是提供给 c ...
- BeyondCorps
This repository provides a short description of the BeyondCorp security model and resources for impl ...
- LeetCode 622. Design Circular Queue
原题链接在这里:https://leetcode.com/problems/design-circular-queue/ 题目: Design your implementation of the c ...
- three.js 设置透明度
原文:https://www.cnblogs.com/amy2011/p/6148736.html 材质: 材质就像物体的皮肤,决定了几何体的外表,例如是否像草地/金属,是否透明,是否显示线框等 Th ...
- 网络协议 11 - Socket 编程(下)
之前我们基本了解了网络通信里的大部分协议,一直都是在“听”的过程.很多人都会觉得,好像看懂了,但关了页面回忆起来,好像又什么都没懂.这次咱们就“真枪实弹”的码起来,再用一个“神器”-网络分析系统详细跟 ...
- mysql实现行转列功能
实现从图一转行成图二的功能: 图一: 图二: 建表语句: CREATE TABLE `t_user_score` ( `id` ) NOT NULL AUTO_INCREMENT COMMENT '主 ...
- 11-散列2 Hashing (25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...
- python requests 上传excel数据流
headers=self.headers #获取导入模版 file_home = self.import_template log.info(file_home) wb = load_workbook ...
- 使用Java将搜狗词库文件(文件后缀为.scel)转为.txt文件
要做一个根据词库进行筛选主要词汇的功能,去搜狗下载专业词汇词库时,发现是.scel文件,且通过转换工具(http://tools.bugscaner.com/sceltotxt/)转换为txt时报错如 ...