读书人

spring引文配置文件解析

发布时间: 2012-10-24 14:15:58 作者: rapoo

spring注解配置文件解析

1、applicationContext.xml

?

<?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:tx="http://www.springframework.org/schema/tx"
?xmlns:context="http://www.springframework.org/schema/context"
?
?xsi:schemaLocation="http://www.springframework.org/schema/beans? http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
???http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
???http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

??? <description>数据访问的配置文件</description>
???
????
???? <!-- 导入配置文件 -->
??? <bean id="propertyConfigurer" />
?? ?<context:component-scan base-package="com.ztev.webapp" />
?? ?
?? ?<!-- 数据源配置 -->
?? ?<bean id="dataSource" destroy-method="close">
?? ? ?<property name="driverClassName" value="${jdbc.driverClassName}"/>
??????? <property name="url" value="${jdbc.url}"/>
??????? <property name="username" value="${jdbc.username}"/>
??????? <property name="password" value="${jdbc.password}"/>
??????? <!-- 以下设置解决connection reset问题 -->
??????? <property name="testOnBorrow" value="true" />
??<property name="testWhileIdle" value="true" />
??<property name="validationQuery" value="select 1" />
??? </bean>
???
??? <!-- 分页实例 -->
??? <bean id="pagination" ref="dataSource"/>
??? </bean>
??
???
??? <!-- 数据库的事务管理器配置 -->
?<bean id="transactionManager" ref="dataSource" />
?</bean>

?<!-- 使用annotation定义数据库事务,这样可以在类或方法中直接使用@Transactional注解来声明事务 -->
?<tx:annotation-driven transaction-manager="transactionManager" />

</beans>

?

?

?

2、fipmis-servlet.xml

?

<?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:p="http://www.springframework.org/schema/p"
?xmlns:context="http://www.springframework.org/schema/context"

?xsi:schemaLocation="http://www.springframework.org/schema/beans? http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
?http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

?<description>与web相关的配置</description>

?<!-- 显示层采用JSTL -->
?<bean id="viewResolver"
??/>
??<property name="prefix" value="/pages/" />
??<property name="suffix" value=".jsp" />
?</bean>

?<!--
??启动Spring MVC的注解功能,完成请求和注解POJO的映射,也可由<context:annotation-config/>启动
??<bean
??value="30000000" />
?</bean>

?<!-- 登陆拦截器 -->
?<bean id="loginInterceptor" value="/index.jsp"/>
?</bean>
?
?<bean id="urlMappingManualLogin" autowire="no"
??/>
???</list>
??</property>
?</bean>
?
</beans>

?

?

?

3、config.xml

?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
?
?<comment>系统配置</comment>
?
?<!-- 数据库相关配置? ====================================================================================== -->
?
?<!-- 数据库配置 -->
?<entry key="jdbc.driverClassName">net.sourceforge.jtds.jdbc.Driver</entry>
?<entry key="jdbc.url">jdbc:jtds:sqlserver://127.0.0.1:1433/fipmis;charset=gbk</entry>
?<entry key="jdbc.username">sa</entry>
?<entry key="jdbc.password">123456</entry>
?
?<!-- 地图服务相关的配置 -->
?<entry key="map.server.host">127.0.0.1</entry><!-- 地图主机地址,如果为空则视为和web服务在同一台服务器上 -->
?<entry key="map.server.port"></entry><!-- 地图服务端口,如果为空则视为web默认端口,即80 -->
?<entry key="map.server.path">fipmismap</entry><!-- 地图服务路径,即IIS中发布的虚拟目录名称 -->
?
?
?<!-- 上传目录及权限限制 -->
?<entry key="file.base.uri">/uploads/file</entry>
?<entry key="files.denied">jsp,vm,cgi,dll,asp,php,aspx,pl,exe</entry>
</properties>

读书人网 >软件架构设计

热点推荐