模板:

<?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-4.0.xsd">
<bean id="moocAppctx" class="imooc_spring.test.aware.MoocApplicationContext"
init-method="hhhh">
</bean>
</beans>

更全面的一个模板,20170327添加,

 <?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"
xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
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-4.0.xsd">
<bean id="moocAppctx" class="imooc_spring.test.aware.MoocApplicationContext"
init-method="hhhh">
</bean> <!-- 引入db.properties -->
<context:property-placeholder location="classpath:db.properties" /> <!-- 配置C3P0数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="driverClass" value="${jdbc.driverName}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.pwd}"></property>
</bean> <!-- 配置 Spring 的 org.springframework.jdbc.core.JdbcTemplate -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean> <bean id="moocBeanNameAware" class="imooc_spring.test.aware.MoocBeanNameAware"></bean> <!-- 测试 SpEL: 可以为属性进行动态的赋值(了解) -->
<bean id="girl" class="com.helloworld.User">
<property name="userName" value="周迅"></property>
</bean> <!-- <bean id="boy" class="com.helloworld.User" init-method="init" destroy-method="destroy">
<property name="userName" value="高胜远"></property> <property name="wifeName"
value="#{girl.userName}"></property> </bean> --> <bean id="girl2" class="com.helloworld.User2">
<property name="userName" value="Talor Swift"></property>
</bean> <!-- autowired测试,自动装配测试 -->
<bean id="people" class="test.spring.autowired.Person" scope="prototype"
autowire="byName">
<property name="name" value="小明"></property>
<!-- <property name="cat" ref="cat222"></property> -->
<!-- <property name="cat" ref="cat1"></property> -->
</bean> <bean id="cat" class="test.spring.autowired.Cat" scope="prototype">
<property name="name" value="波斯猫"></property>
</bean>
<!-- <bean id="cat222" class="test.spring.autowired.Cat"> <property name="name"
value="我是小喵喵"></property> </bean> --> <bean id="people2" class="test.spring.autowired.Person" scope="prototype"
autowire="byName">
<property name="name" value="小明"></property>
<property name="cat" ref="cat222"></property>
</bean> <bean id="cat222" class="test.spring.autowired.Cat" scope="prototype">
<property name="name" value="波斯猫"></property>
</bean> <!--context:component-scan 指定 扫描的包 -->
<!--可以通过 resource-pattern 指定扫描的资源, resource-pattern="myrepository/*.class"
的含义: 只扫描 base-package 对应包下的 目录为 myrepository 的所有java Bean -->
<!-- <context:component-scan base-package="imooc_spring.test.anotation"
resource-pattern="myrepository/*.class"></context:component-scan> --> <!-- context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"
子节点指定排除哪些注解 context:include-filter type="annotation" 需要结合context:component-scan
标签的 use-default-filters="false"来使用 context:exclude-filter type="assignable"
这个expression指的是自己写的类,意思排除哪些类 expression="imooc_spring.test.anotation.TestObj" -->
<context:component-scan base-package="imooc_spring.test.anotation">
<!-- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"
/> --> <!-- <context:exclude-filter type="assignable" expression="imooc_spring.test.anotation.TestObj"
/> --> </context:component-scan>
<context:component-scan base-package="com.aop"></context:component-scan> <!-- aop测试,需要引入aop命名空间 -->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy> <!-- aop annotationType, --> <!-- 切点的bean -->
<bean class="com.aop.xmltype.CalculatorImplxml" id="calImplxml"></bean>
<!-- 切面的bean -->
<bean class="com.aop.xmltype.MyAspectxml" id="myaspxml"></bean> <bean class="com.aop.xmltype.Diary" id="myDiary"></bean>
<!-- aop xmlType,用xml的形式配置AOP前置通知 -->
<aop:config>
<!--aop:pointcut 其实放在这儿也可以 -->
<!-- <aop:pointcut expression="execution (* com.aop.xmltype.CalculatorImplxml.*(..))"
id="pointcut1" /> --> <!-- 配置切面和通知 ,aop:aspect标签需要通过ref指定配置好的bean,id随便配置或者不配置,id的值可以随意起 -->
<aop:aspect id="myaspxml" ref="myaspxml" order="2">
<!-- 配置切点,即 要被记日记的对象, aop:pointcut 放在这儿也可以 ,切点不需要根对应的bean相关联,
只要expression指定的方法所在的类被Spring扫描得到就行,即只要所在的类配置了bean就可以 -->
<aop:pointcut expression="execution (* com.aop.xmltype.CalculatorImplxml.*(..))"
id="pointcut1" />
<!-- 切面里的具体的用于记录的方法就是一个通知,需要用通过pointcut-ref来指定具体的切点, -->
<aop:before method="logBefore" pointcut-ref="pointcut1" />
<aop:after method="logAfter" pointcut-ref="pointcut1" />
</aop:aspect> <aop:aspect ref="myDiary" order="3">
<!-- execution (* com.aop.*.*.*(..)) 包含了 com.aop.xmltype.CalculatorImplxml.*(..)) 的这种情况 -->
<!-- <aop:pointcut expression="execution (* com.aop.*.*.*(..))" id="allPointcut"/> -->
<aop:pointcut expression="execution (* com.aop.xmltype.CalculatorImplxml.*(..))" id="allPointcut"/>
<aop:before method="myEnd" pointcut-ref="allPointcut"/>
</aop:aspect> </aop:config> </beans>

所在项目:

Spring配置文件模板的更多相关文章

  1. 关于spring配置文件的头部编写

    //普通spring配置文件模板1 <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns: ...

  2. ssh框架中spring整合hibernate的配置文件模板(带详细注释)

    applicationContext.xml的配置文件模板 <?xml version="1.0" encoding="UTF-8"?> <b ...

  3. 你不知道的Spring配置文件

    Spring配置文件是用于指导Spring工厂进行Bean生产.依赖关系注入(装配)及Bean实例分发的"图纸".Java EE程序员必须学会并灵活应用这份"图纸&quo ...

  4. Spring配置文件详解

      转自: http://book.51cto.com/art/201004/193743.htm 此处详细的为我们讲解了spring2.5的实现原理,感觉非常有用 spring配置文件是用于指导Sp ...

  5. spring配置文件详解--真的蛮详细

    spring配置文件详解--真的蛮详细   转自: http://book.51cto.com/art/201004/193743.htm 此处详细的为我们讲解了spring2.5的实现原理,感觉非常 ...

  6. Spring 配置文件详解 (以2.5为例)

    转载自:http://blog.csdn.net/zzjjiandan/article/details/22922847          Spring配置文件是用于指导Spring工厂进行Bean生 ...

  7. JdbcTemplae使用入门&&Spring三种连接池配置&&Spring配置文件引用外部properties文件

    JdbcTemplate的使用 Spring为了各种支持的持久化技术,都提供了简单操作的模版和回调. JdbcTemplate 简化 JDBC 操作HibernateTemplate 简化 Hiber ...

  8. J2EE进阶(四)Spring配置文件详解

    J2EE进阶(四)Spring配置文件详解 前言 Spring配置文件是用于指导Spring工厂进行Bean生产.依赖关系注入(装配)及Bean实例分发的"图纸".Java EE程 ...

  9. spring配置文件详解以及beans:beans标签

    第一行的意思就是你这个文件的默认schema为security,所以你的beans定义就需要加上前缀beans 一般的定义文件默认都是beans: 下面是spring配置文件的详解: 转自:http: ...

随机推荐

  1. ios中的银联支付

    场景 随着移动互联网的迅猛发展,移动互联已经深深地融入我们的生活.其中,支付方式也是我们生活中经常遇到的情况.所以,在我们的应用中加入支付功能是多么的重要.现在主流的支付接口,一是支付宝类的,一是银联 ...

  2. Java图形化界面设计——布局管理器之null布局(空布局)

    一般容器都有默认布局方式,但是有时候需要精确指定各个组建的大小和位置,就需要用到空布局. 操作方法: 1)       首先利用setLayout(null)语句将容器的布局设置为null布局(空布局 ...

  3. CF#52 C Circular RMQ (线段树区间更新)

    Description You are given circular array a0, a1, ..., an - 1. There are two types of operations with ...

  4. Unslider – 轻量的响应式 jQuery 内容轮播插件

    Unslider 是一款非常轻量的 jQuery 插件(压缩后不到3KB),能够用于任何 HTML 内容的滑动. 可以响应容器的大小变化,自动排布不用大小的滑块.可以通过整合 jQuery.event ...

  5. 2015年最棒的10个 JavaScript 框架

    JavaScript是最流行的前端开发程序设计语言.它为WEB开发者提供了能够设计出具有丰富功能.干净用户界面的WEB应用的能力.JavaScript框架使得WEB应用的设计变的简单,并且它能够提供很 ...

  6. c++ primer plus 习题答案(6)

    p425.1 #include<iostream> #include<cstring> #include<cstdlib> using namespace std; ...

  7. 理解Python的with as语句

    简单的说, with open(filepath, 'wb') as file: file.write("something") 等价于: file = open(filepath ...

  8. gdal 1.9+python 2.7开发环境配置

    最近项目使用Cesium平台基于WegGl做web地球,其中关于地形数据有一种支持格式为terrain的地形数据.这种格式可以通过一个python工具切dem来得到. 下面记录下配置gdal+pyth ...

  9. IOS 单例模式的学习

    单例模式只能修改无法释放,直到程序结束. 我们下面一步一步来做一个单例模式程序 (1)单例一旦创建,是永远存在于内存中的,所以需要创建一个全局量 static MySingletonClass *sh ...

  10. QT IP输入框正则表达式(使用QLineEdit的setValidator函数)

    /* ip输入框正则表达式 */ // IP 前3段 QRegExp regExp("[0-9][0-9.][0-9.][.]"); ui->lineEdit_1->s ...