配置的具体解释可以参考米米商城项目实战 ssm框架部分

pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>ysk</groupId><artifactId>mimiMall</artifactId><version>1.0</version><packaging>war</packaging><!-- 集中定义依赖版本号 --><properties><junit.version>4.12</junit.version><spring.version>5.2.5.RELEASE</spring.version><mybatis.version>3.5.1</mybatis.version><mybatis.spring.version>1.3.1</mybatis.spring.version><mybatis.paginator.version>1.2.15</mybatis.paginator.version><mysql.version>5.1.9</mysql.version><slf4j.version>1.6.4</slf4j.version><druid.version>1.1.12</druid.version><pagehelper.version>5.1.2</pagehelper.version><jstl.version>1.2</jstl.version><servlet-api.version>3.0.1</servlet-api.version><jsp-api.version>2.0</jsp-api.version><jackson.version>2.9.6</jackson.version></properties><dependencies><!-- spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jms</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>${spring.version}</version></dependency><!-- Mybatis --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>${mybatis.version}</version></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>${mybatis.spring.version}</version></dependency><dependency><groupId>com.github.miemiedev</groupId><artifactId>mybatis-paginator</artifactId><version>${mybatis.paginator.version}</version></dependency><dependency><groupId>com.GitHub.pagehelper</groupId><artifactId>pagehelper</artifactId><version>${pagehelper.version}</version></dependency><!-- MySql --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.version}</version></dependency><!-- 连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>${druid.version}</version></dependency><!-- junit --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${junit.version}</version><scope>test</scope></dependency><!-- JSP相关 --><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId><version>${jstl.version}</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.0.1</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jsp-api</artifactId><scope>provided</scope><version>${jsp-api.version}</version></dependency><!-- Jackson Json处理工具包 --><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>${jackson.version}</version></dependency><!-- 文件异步上传 --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.4</version></dependency><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.3.1</version></dependency>
</dependencies><!-- 插件配置 --><!-- 每个plugins就是一个插件 -->
<build>
<plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin>
</plugins>
<!--识别所有的配置文件-->
<resources><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource>
</resources>
</build></project>

jdbc.properties

jdbc.url=jdbc:mysql://localhost:3306/数据库名称
jdbc.username=root
jdbc.passwd=123
jdbc.max=30

applicationContext_dao.xml

datasource爆红可忽略!

<?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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><!--配置属性文件--><!--在资源配置文件中的根目录进行查找--><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!--声明数据源DataSource, 作用是连接数据库的--><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"init-method="init" destroy-method="close"><property name="url" value="${jdbc.url}"/><!--setUrl()--><property name="username" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/><property name="maxActive" value="${jdbc.max}"/></bean><!--配置mybatis工厂--><bean class="org.mybatis.spring.SqlSessionFactoryBean"><!--配置数据源--><property name="dataSource" ref="dataSource"></property><!--配置mybatis的核心配置文件--><property name="configLocation" value="classpath:mybatis.xml"></property><!--配置实体类--><property name="typeAliasesPackage" value="ysk.pojo"></property></bean><!--配置mapper所在的包--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="ysk.mapper"></property></bean></beans>

applicationContext_service.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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd"><!--<import resource="classpath:applicationContext_dao.xml"></import>--><!--    设置业务逻辑层的包扫描器,目的是在指定的路径下,使用@Service注解的类,Spring负责创建对象,并添加依赖--><context:component-scan base-package="ysk.service"></context:component-scan><!--    设置事物管理器--><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><!--    添加事务的切面--><!--    查询的时候不能更改,所以是true--><tx:advice id="myadvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="*select*" read-only="true"/><tx:method name="*find*" read-only="true"/><tx:method name="*get*" read-only="true"/><tx:method name="*search*" read-only="true"/><tx:method name="*insert*" propagation="REQUIRED"/><tx:method name="*save*" propagation="REQUIRED"/><tx:method name="*add*" propagation="REQUIRED"/><tx:method name="*delete*" propagation="REQUIRED"/><tx:method name="*remove*" propagation="REQUIRED"/><tx:method name="*clear*" propagation="REQUIRED"/><tx:method name="*update*" propagation="REQUIRED"/><tx:method name="*modify*" propagation="REQUIRED"/><tx:method name="*change*" propagation="REQUIRED"/><tx:method name="*set*" propagation="REQUIRED"/><tx:method name="*" propagation="SUPPORTS"/></tx:attributes></tx:advice><!--    完成切面和切入点的织入-->
<!--    切入点的表达式execution()指明哪些包哪些类哪些方法需要应用这些管理,-->
<!--    刚开始*表示任意返回值类型,-->
<!--    指定这个包,所有的类.*,类中所有方法.*,参数任意(..)。绑定是绑定切面 以及切入点。--><aop:config><aop:pointcut id="mypointcut" expression="execution(* ysk.service.*.*(..))"/><aop:advisor advice-ref="myadvice" pointcut-ref="mypointcut"></aop:advisor></aop:config>
</beans>

mybatis.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><!--settings:控制mybatis全局行为--><settings><!--设置mybatis输出日志--><setting name="logImpl" value="STDOUT_LOGGING"/></settings><!--    分页插件的配置--><plugins><plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin></plugins></configuration>

springmvc.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: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.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd"><!--    设置包扫描器--><context:component-scan base-package="ysk.controller"></context:component-scan><!--    设置视图解析器   /admin/     main    .jsp  --><bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/admin/"></property><property name="suffix" value=".jsp"></property></bean><!--    设置文件上传核心组件--><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"></bean><!--    设置注解驱动--><mvc:annotation-driven></mvc:annotation-driven>
</beans>

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_4_0.xsd"version="4.0"><!--    添加字符编码过滤器--><filter><filter-name>encode</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><init-param><param-name>forceRequestEncoding</param-name><param-value>true</param-value></init-param><init-param><param-name>forceResponseEncoding</param-name><param-value>true</param-value></init-param></filter><filter-mapping><filter-name>encode</filter-name><url-pattern>/*</url-pattern></filter-mapping><!--    注册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:springmvc.xml</param-value></init-param></servlet><servlet-mapping><!--/admin/login.action/admin/main.jsp--><servlet-name>springmvc</servlet-name><url-pattern>*.action</url-pattern></servlet-mapping><!--    注册Spring框架--><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext_*.xml</param-value></context-param><welcome-file-list><welcome-file>/admin/login.jsp</welcome-file></welcome-file-list>
</web-app>

ssm整合开发配置文件相关推荐

  1. 阿里开发规范文档_华为阿里等技术专家15年开发经验总结:SSM整合开发实战文档...

    前言 Spring自2002年诞生至今,已有近20年的历史,虽然几经变迁,但始终在继续发展和精进.Spring目前由Pivotal维护和开发. Pivotal是PaaS(平台即服务)的领导者,也是消息 ...

  2. SSM整合开发学习笔记

    1. 整合配置 1.1 配置项目依赖 <?xml version="1.0" encoding="UTF-8"?><project xmlns ...

  3. SSM 整合开发初见面

    SpringMVC是Spring其中的一个模块,我们直接使用即可: SSM的整合:将Mybatis 和 Spring进行整合: >类的根路径:classpath,也就是classes文件夹 sr ...

  4. 手把手教你SSM整合开发办公系统(OA)——报销单(含源码)

    文章目录 前言 项目展示 技能要求 一.开始前的准备 1.OA系统是什么? 2.人员权利与报销流程 3.数据库设计 4.创建项目及作用说明 5.包与全局变量配置 6.编写过滤器 7.静态资源的复制与请 ...

  5. SSM整合时配置文件的编写

    编写web.xml 1.配置项目初始化时启动Spring容器 传递参数,spring配置文件的位置 <context-param><param-name>contextConf ...

  6. SSM整合(配置文件)

    Web.XML <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="htt ...

  7. ssm整合开发 动力节点王鹤版本

    目录 介绍 整合 1. pom.xml 2. web.xml 3. 新建包.目录.文件 4. applicationContext.xml 5. dispatcherServlet.xml 6. jd ...

  8. OA办公自动化系统~~~SSM整合开发

    简介:    OA( Office Automation System)办公自动化系统是一个企业用来管理日常事务的系统,它一般用来管理各种流程(报销.请假. . .)审批,通讯录.日程.文件管理.通知 ...

  9. 记第一次ssm整合的配置文件

    applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...

最新文章

  1. HTC VIVE SDK 中的例子 hellovr_opengl 程序流程分析
  2. pdf怎么转html?
  3. GAN在Image To Image translation 和Inverse Problem中的应用
  4. ITK:运算后的当前图像
  5. ios nsstring根据ascii码大小排序_iOS(NSPredicate) 谓词的使用
  6. etmvc mysql乱码_etmvc中集成spring使用druid连接池
  7. Go 模块--开始使用 Go Modules
  8. android 功能清单文件夹,全新Android L大小全部功能清单整理
  9. Crackme017
  10. Inpaint 9 简体中文【订阅版+Win/Mac】
  11. 计算机程序设计艺术读书感悟
  12. 微信开发者工具通过二维码编译步骤
  13. (附源码)springboot社区疫苗接种管理系统 毕业设计 281442
  14. 学大数据要学哪些算法_大数据专业是学什么?
  15. Active X控件在IE上自动下载并注册
  16. bp神经网络原理 实现过程,bp神经网络的应用案例
  17. html图片加载不出来
  18. 什么是二极管的频率特性
  19. cocos creator 支持gif
  20. 目录和文件暴露在根目录下的 nginx 配置演示

热门文章

  1. 数据库的数据文件和日志文件
  2. 三个月速成Java--一些小建议和感概
  3. SSD NVMe核心之PRP算法
  4. 武汉Java程序员工资是否还会增长?工资为什么那么高?
  5. 基于Unity3D 的Vuforia SDK开发基础教程
  6. 硕士论文要不要附matlab程序,论文必须要有附录吗_毕业论文附录一定要写吗_毕业论文中附录是不是必须要写的...
  7. L - New Year Snowmen
  8. 微型计算机中什么是小随机储存器,随机存取存储器
  9. 重装系统后出现服务器正在运行中,win7系统重装完后怎么一直显示正在启动 - 卡饭网...
  10. Maximum Mean Discrepancy理解(MMD)