spring的一些配置

ApplicationContext配置

<!-- 自动扫描包 加载annotation类 -->
<context:component-scan base-package="com.xxx.xx" />

<!-- 加载properties配置文件 -->
<context:property-placeholder location="classpath:config.properties" />

<!-- 加载JdbcTemplate配置文件 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
      <property name="dataSource" ref="dataSource" />
</bean>

<!-- 加载dataSource配置文件 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close">
      <property name="jdbcUrl" value="${jdbc.url}"></property>
      <property name="driverClass" value="${jdbc.driverClassName}"></property>
      <property name="user" value="${jdbc.username}"></property>
      <property name="password" value="${jdbc.password}"></property>
      <property name="maxPoolSize" value="40"></property>
      <property name="minPoolSize" value="1"></property>
      <property name="initialPoolSize" value="1"></property>
      <property name="maxIdleTime" value="20"></property>
</bean>

<aop:config>
      <!-- 切入点配置 -->
      <aop:pointcut expression="execution(public * com.prototype..*.*(..))" id="allPointcut"/>
      <aop:aspect id="logAspect" ref="logInterceptorForXml">
            <aop:before method="before" pointcut-ref="allPointcut"/>
            <aop:after method="after" pointcut-ref="allPointcut"/>
      </aop:aspect>
</aop:config>

 

SpringMVC配置

<!-- 扫描 -->
<context:component-scan base-package="com.prototype.controlle">
      <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

<!-- <mvc:view-controller path="/" view-name="index"/> -->

<mvc:annotation-driven/>

<mvc:resources location="/resource/" mapping="/resource/**"></mvc:resources>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/view/"/>
    <property name="suffix" value=".jsp"/>
</bean>

 

posted @ 2018-01-11 14:04  没有听见下雨的声音  阅读(100)  评论(0编辑  收藏  举报