ssm基本配置文件
来源:互联网 发布:知乎 复制 编辑:程序博客网 时间:2024/06/14 11:31
web.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>ssm0908</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- SpringMVC配置 -->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/springMVC-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- spring 通过ContextLoaderListener 监听器来创建 IOC容器 执行顺序:监听器->过滤器->servlet -->
<!-- 配置spring配置文件 路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/applicationcontext.xml</param-value>
</context-param>
<!-- 应用程序启动则创建了IOC容器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
springMVC配置
<?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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- 扫描控制器对象 -->
<context:component-scan base-package="com.etc.controller" />
<mvc:annotation-driven />
<!-- 静态资源访问 -->
<mvc:resources location="/images/" mapping="/images/**" />
<mvc:resources location="/js/" mapping="/js/**" />
<mvc:resources location="/css/" mapping="/css/**" />
<!-- 视图分解 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
spring配置
<?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"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
">
<!-- 只需扫描 业务逻辑层的类,因为控制层由springMVC配置文件扫描,,实体对象和Dao层数据访问接口由 MyBatis配置文件扫描. -->
<context:component-scan base-package="com.etc.service" />
<mvc:annotation-driven/>
<!-- 加载数据库的属性文件 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:config/jdbc.properties"></property>
</bean>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/myschool?characterEncoding=utf-8" />
<property name="username" value="root" />
<property name="password" value="123123" />
<property name="initialSize" value="5" />
<property name="maxActive" value="50" /> <!-- 最大连接数 -->
<property name="maxIdle" value="10" /> <!-- 最大空闲连接数 -->
<property name="minIdle" value="5" /> <!--最小空闲连接数 -->
<property name="maxWait" value="120000" /> <!-- 最大空闲时间 : 2分钟 毫秒-->
</bean>
<!-- 配置MyBatis SqlSessionFactory SqlSession->数据访问接口 -->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 关联数据源 -->
<property name="dataSource" ref="dataSource" />
<!-- 加载数据访问接口映射文件 -->
<property name="mapperLocations" value="classpath:com/etc/dao/*.xml" />
<!-- 加载MyBatis的主配置文件 -->
<property name="configLocation" value="classpath:config/mybatis-config.xml" />
<!-- 加载实体类的别名 <property name="typeAliases" value="classpath:com.etc.entity"/> -->
</bean>
<!-- 扫描加载所有的数据访问接口 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactory" ref="sqlSessionFactoryBean" />
<property name="basePackage" value="com.etc.dao" />
</bean>
<!-- 事务配置 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
mybatis配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 给实体对象取另名 -->
<typeAliases>
<package name="com.etc.entity"/>
</typeAliases>
</configuration>
- ssm基本配置文件
- SSM配置文件
- SSM配置文件
- ssm配置文件
- SSM配置文件
- ssm配置文件
- SSM 配置文件
- ssm配置文件
- maven-ssm框架基本整合之配置文件的配置
- SSM配置文件-web.xml
- SSM框架的配置文件
- SSM整合之配置文件
- ssm整合的配置文件
- SSM配置文件详解
- SSM + freeMarker配置文件
- SSM框架配置文件整理
- ssm 配置文件配置
- ssM框架简单配置文件
- Unity3D的WWW类使用
- HDU 5532 Almost Sorted Array——LIS
- 值得推荐的C/C++框架和库 (真的很强大)
- activiti(7):监听器之流程监听及spring注入
- 如何写SysV服务管理脚本
- ssm基本配置文件
- 版本更新简要
- Google Developers 认证团队推出 Mobile Web Specialist 认证
- 安装grunt-contrib-qunit报错,报错信息:! phantomjs-prebuilt@2.1.15 install: `node install.js`
- koa-router介绍
- source insight 4常用设置
- git 无法使用ssh协议连接
- 自定义属性使用
- 欧拉回路--输出欧拉回路的路径