1.Spring的注解开发
来源:互联网 发布:python 日志文件 编辑:程序博客网 时间:2024/05/22 04:44
注解开发流程:
1)Spring的注解开发除了四个核心jar还需要aop包的支持,引入pring-aop-4.3.2.RELEASE.jar.
2)在配置文件中引入约束schema.
3)开启注解扫描.
1.注解约束schema:spring-context.xsd配置.
在配置文件中需要引入注解的约束:
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
原文如下:
41.2.8 the context schema
The context
tags deal with ApplicationContext
configuration that relates to plumbing- that is, not usually beans that are important to an end-user but rather beans that doa lot of grunt work in Spring, such as BeanfactoryPostProcessors
. The followingsnippet references the correct schema so that the tags in the context
namespace areavailable to you.
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- bean definitions here --></beans>
2.开启注解扫描:
<!-- 开启注解扫描 到包里面扫描类、方法、属性上面是否有注解 (开发一般建议使用) --> <context:component-scan base-package="cn.com.yves"></context:component-scan> <!-- 只扫描属性上面的注解 --> <!-- <context:annotation-config></context:annotation-config> -->
注意:
- 1.在类上使用注解的时候,默认的是调用的无参构造方法来实例化对象的.
- 2如果是多个不同的包可以在配置多个值在base-package属性中,比如配置扫描cn.com.yves和cn.com.utils包下java类,中间用逗号
,
隔开<context:component-scan base-package="cn.com.yves,cn.com.utils"></context:component-scan>
阅读全文
0 0
- 1.Spring的注解开发
- spring的注解开发模式
- Spring 基于注解的开发
- spring bean的注解开发
- spring注解开发AnnotationConfigApplicationContext的使用
- spring注解开发AnnotationConfigApplicationContext的使用
- spring注解开发AnnotationConfigApplicationContext的使用
- 【Java-Spring开发】aop注解 自定义切面的注解写法
- spring MVC 注解开发
- Spring bean注解开发
- Spring 注解开发
- spring AOP 注解开发
- Spring IOC注解开发
- spring之注解开发
- spring注解开发
- Spring注解开发
- Spring MVC注解开发
- Spring注解开发
- 数据库学习——排序
- Splunk-SDK-Python学习
- CSS控制文字只显示一行,超出部分显示省略号
- ContentProvider分析(一)之TelephonyProvider的初始化
- IO复用 socket epoll
- 1.Spring的注解开发
- 学习笔记之面向对象编程19(流之Reader,Writer)
- 九度机试笔记20170908
- Java虚拟机内存分布与介绍
- VS控制台程序Socket通讯
- golang命令行库cobra的使用
- 非规范的maven项目打包路径指定
- HDU1037
- 通过一个实例让你快速学习java反射