SSM框架中常用的配置文件

学习框架,刚开始的时候最烦的就是一些配置文件,有很多需要配置的东西,今天把这些配置文件信息稍微整理一下,以后说不定会用的到。

web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"version="3.1"><!-- 配置加载Spring文件的监听器--><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 编码过滤器 --><filter><filter-name>encoding</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>encoding</filter-name><url-pattern>*.action</url-pattern></filter-mapping><!-- 配置Spring MVC前端核心控制器 --><servlet><servlet-name>crm</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:springmvc-config.xml</param-value></init-param><!-- 配置服务器启动后立即加载Spring MVC配置文件 --><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>crm</servlet-name><url-pattern>*.action</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list>
</web-app>

springmvc的配置文件 springmvc-config.xml

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.3.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.3.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-4.3.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.3.xsd"><!-- 加载属性文件 --><context:property-placeholder location="classpath:resource.properties"/><!-- 配置扫描器 --><context:component-scan base-package="com.ma.core.web.controller"/><!-- 注解驱动:配置处理器映射器和适配器 --><mvc:annotation-driven/><!--配置静态资源的访问映射,此配置中的文件,将不被前端控制器拦截 --><mvc:resources mapping="/js/**" location="/js/"/><mvc:resources mapping="/css/**" location="/css/"/><mvc:resources mapping="/fonts/**" location="/fonts/"/><mvc:resources mapping="/images/**" location="/images/"/><!-- 配置视图解释器ViewResolver --><bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/jsp/"/><property name="suffix" value=".jsp"/></bean><!--配置拦截器--><mvc:interceptors><mvc:interceptor><mvc:mapping path="/**"/><bean class="com.ma.core.interceptor.LoginInterceptor"/></mvc:interceptor></mvc:interceptors></beans>

applicationContext.xml文件

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.3.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.3.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-4.3.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.3.xsd"><!--读取db.properties--><context:property-placeholder location="classpath:db.properties"/><!--配置数据源--><bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"><!--数据库驱动--><property name="driverClassName" value="${jdbc.driver}"/><!--连接数据库的url--><property name="url" value="${jdbc.url}"/><!--连接数据库的用户名--><property name="username" value="${jdbc.username}"/><!--连接数据库的密码--><property name="password" value="${jdbc.password}"/><!--最大连接数--><property name="maxTotal" value="${jdbc.maxTotal}"/><!--最大空闲数--><property name="maxIdle" value="${jdbc.maxIdle}"/><!--初始化连接数--><property name="initialSize" value="${jdbc.initialSize}"/></bean><!-- 事务管理器,依赖于数据源--><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!--通知--><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><!--传播行为--><tx:method name="save*" propagation="REQUIRED"/><tx:method name="insert*" propagation="REQUIRED"/><tx:method name="add*" propagation="REQUIRED"/><tx:method name="create*" propagation="REQUIRED"/><tx:method name="delete*" propagation="REQUIRED"/><tx:method name="update*" propagation="REQUIRED"/><tx:method name="find*" propagation="SUPPORTS" read-only="true"/><tx:method name="select*" propagation="SUPPORTS" read-only="true"/><tx:method name="get*" propagation="SUPPORTS" read-only="true"/></tx:attributes></tx:advice><!--切面--><aop:config><aop:advisor advice-ref="txAdvice" pointcut="execution(* com.ma.core.service.*.*(..))"/></aop:config><!--配置MyBatis工厂SqlSessionFactory--><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!--注入数据源--><property name="dataSource" ref="dataSource"/><!--指定mapper文件的位置--><property name="mapperLocations" value="classpath:mybatis/sqlmap/*.xml"/><!--指定MyBatis的核心配置文件--><property name="configLocation" value="classpath:mybatis-config.xml"/></bean><!-- 接口开发,扫描 com.itheima.core.dao包 ,写在此包下的接口即可被扫描到 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.ma.core.dao"/></bean><!-- 配置扫描@Service注解 --><context:component-scan base-package="com.ma.core.service"/></beans>

mybatis的配置文件mybatis-config.xml

<?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.ma.core.po" /></typeAliases>
</configuration>

db.properties文件

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=root
jdbc.password=
jdbc.maxTotal=30
jdbc.maxIdle=10
jdbc.initialSize=5

log4j.properties文件

# Global logging configuration
log4j.rootLogger=ERROR, stdout
# MyBatis logging configuration...
log4j.logger.com.ma.core=DEBUG
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

小结

以上是SSM框架基本的配置文件,还有很多其它的配置文件,到时候再加吧。

转载于:https://www.cnblogs.com/black-spike/p/7872893.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/368665.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

html 消息通知声音,ajax实现web页面的消息实时提醒时播放提示音

在应用系统的开发过程中&#xff0c;经常要使用到新消息的提醒功能&#xff0c;比如说后台有一个告警消息&#xff0c;web页面就会实时的收到这个告警的消息&#xff0c;且发出提示音。这其实就是涉及到两个方面的知识&#xff0c;一个是http实时消息的推送&#xff0c;在这儿我…

元素的居中方式总结

最近有点空闲时间&#xff0c;所以想好好看看几个一直没机会看的问题。把它写下来&#xff0c;是促进自己更好地理解&#xff0c;同时也是一个备忘吧&#xff01; 先说元素居中&#xff0c;元素居中&#xff0c;从最开始接触前端就一直挥之不去的一个问题&#xff0c;也许是太…

Man方法

Main方法相当一个主线程&#xff0c;JVM会自动寻找class文件中的main方法并执行(请思考tomcat加载java web项目启动的线程数和每次tomcat服务器接收到请求&#xff0c;是不是要发起一个线程去处理) 以下的例子展现了Main主线程中启动了两个分支线程&#xff08;mTh1和mTh2) pac…

八、网络服务集群

概述 neutron-server 接收和路由API请求到合适的OpenStack网络插件&#xff0c;以达到预想的目的。 5.1、控制节点安装 5.1.1、先决条件 在你配置OpenStack网络&#xff08;neutron&#xff09;服务之前&#xff0c;你必须为其创建一个数据库&#xff0c;服务凭证和API端点。 1…

JArchitect对Java开源贡献者免费

JArchitect是用于Java代码库的静态分析工具&#xff0c;它提供交互式GUI和HTML报告&#xff0c;用于查找代码中过于复杂或有问题的区域&#xff0c;执行分析以重构并比较随时间的变化。 在版本3中&#xff0c;添加了类似LINQ的查询语言&#xff0c;该工具使该工具成为功能极其强…

android让一个控件跟上面控件对其,学个明白--Android控件架构

Android控件架构1.什么是View&#xff1f;View是Android中所有控件的基类。View是界面层的控件的一种抽象&#xff0c;它代表了一个控件。在Android中每个控件都会在界面中占得一块矩形的区域。在Android中控件被分为两类&#xff1a;View和ViewGroup。ViewGroup控件作为父控件…

分享一个自制的计算子网划分的小工具

使用 javascirpt 写的&#xff0c;因此可以使用浏览器浏览即可 code: <meta charset"utf-8">输入划分网段的数量&#xff1a; <input id"inp_netCount" /> <input type"button" οnclick"createElem()" value"sta…

每个Java开发人员应拥有的持久断点

当开发人员使用Java进行工作时&#xff0c;即使您尝试调试其他内容&#xff0c;也总是会遇到一些失败的情况。 这是应该在每个IDE中启用的持久断点的列表。 &#xff08;恕我直言&#xff09; 是的&#xff0c;从理论上讲&#xff0c;您应该能够从良好的日志记录实现中获得此信…

tmux颜色高亮跟vim不一致的情况

安装完tmux之后&#xff0c;按照网上大神的配置&#xff0c;稍微配置了下~/.tmux.conf&#xff1a; # 改变快捷键前缀 unbind C-b set -g prefix C-a # 绑定配置加载按键 bind r source-file ~/.tmux.conf \; display-message "Config reloaded.."# 设置终端类型为2…

html5表白页面3d,七夕节表白3d相册制作(html5+css3)

七夕节表白3d相册制作涉及知识点定位阴影3d转换动画主要思路&#xff1a;通过定位将所有照片叠在一起&#xff0c;在设置默认的样式以及照片的布局&#xff0c;最后通过设置盒子以及照片的旋转动画来达到效果。代码如下&#xff1a;3d相册/* 使用单位将所有照片叠在一起 */img{…

(1)pandas 基础教程

步骤1、环境准备 右击桌面上选择【Open in Terminal】 打开终端。在弹出的终端中输入【ipython】进入Python的解释器中&#xff0c;如图1所示。 图1 ipython解释器步骤2、导入所需要的包 导入实验常用的python包。如图2所示。【import pandas as pd】pandas用来做数据处理。【i…

使用Java WebSockets,JSR 356和JSON映射到POJO的

因此&#xff0c;我一直在研究Tyrus &#xff08;JSR 356 WebSocket for Java规范的参考实现&#xff09;。 因为我一直在寻找测试工具&#xff0c;所以我对在Java中同时运行客户端和服务器端感兴趣。 因此&#xff0c;恐怕此博客文章中没有HTML5。 在此示例中&#xff0c;我们…

CSS3效果:波浪效果

实现效果 如图所示&#xff1a; 首先得准备三张图&#xff0c;一张是浅黄色的背景图loading_bg.png&#xff0c;一张是深红色的图loading.png&#xff0c;最后一张为bolang.png。 css代码 body{background:#ffe894;}.loading_bg{width:113px; height:111px;background:url(lo…

集合、深浅拷贝、文件操作(读、写、追加)函数初识(参数)

小数据池#int比较数值is 比较内存地址id 测试内存地址#str不能含有特俗字符单个元素*数字&#xff0c;不能超过21i1 ‘a’*20i ‘a’*20id一样i1 ‘a’*21i ‘a’*21id不一样编码ascii 英文的数字&#xff0c;字母&#xff0c;特殊字符字节8位表示一个字节字符内容的最小…

html创建文件域的代码,word如何插入域代码

在word里怎么进行域代码的设置&#xff1f;如果知道要插入的域的域代码&#xff0c;可以将其直接键入在文档中。首先按 CtrlF9&#xff0c;然后在括号中键入代码就可以了。【Word插入域方法】1、Word2007中&#xff0c;在要插入域的位置单击。2、在“插入”选项卡上的“文字”组…

大学屌丝男

哈哈&#xff0c;来晚了呀转载于:https://www.cnblogs.com/wainiwann/p/7909765.html

前端页面适配的rem换算

为什么要使用rem 之前有些适配做法&#xff0c;是通过js动态计算viewport的缩放值&#xff08;initial-scale&#xff09;。 例如以屏幕320像素为基准&#xff0c;设置1&#xff0c;那屏幕375像素就是375/3201.18以此类推。 但直接这样强制页面缩放过于粗暴&#xff0c;会导致页…

lt form gt 在html,HTML lt;formgt; 标签的 accept

HTML <form> 标签的 accept2018-11-20在跨业务、跨网站发送数据或者业务升级的时候&#xff0c;我们有的时候需要指定发送数据的编码方式&#xff0c;比如页面表单的编码是UTF-8的&#xff0c;而提交到目标页面的编码是GBK编码时&#xff0c;会用到表单的accept-charset属…

使用Java ThreadLocals的意外递归保护

对于那些使用第三方工具来尝试扩展它们而又不完全了解它们的人来说&#xff0c;这是一个小技巧。 假定以下情况&#xff1a; 您想扩展一个公开分层数据模型的库&#xff08;假设您要扩展Apache Jackrabbit &#xff09; 该库在访问内容存储库的任何节点之前会内部检查访问权限…

今日头条竞价接口转发

一、代码 ①类名 public class TouTiao{public class model{public string site_id { get; set; }public string ad_id { get; set; }public List<Data> data { get; set; }}public class Data{public string label { get; set; }public string lable { get; set; }publi…