1.1 Maven 项目 Pom 管理
<! - 常量和版本号 -> <Properties> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <project.reportting.outputencoding> utf-8 </project.reportting.outputencoding> <comons.beanutils> 1.9.3 </comons.Beanulils> <printemps.version> 4.3.2.release </sspring.version> <aspectj.version> 1.8.6 </aspectj.version> <aspectj.weaver> 1.8.6 </aspectj.weaver> <Mybatis.Spring.version> 1.3.0 </mybatis.spring.version> <Mybatis.version> 3.4.5 <mysql.version> 5.1.32 </mysql.version> <lf4j.version> 1.7.25 </slf4j.version> <lf4j.log4j12.version> 1.7.25 </slf4j.log4j12.version> <log4j.version> 1.2.17 </log4j.version> <log4j.core.version> 2.3 </log4j.core.version> <commons.logging.version> 1.2 </commons.logging.version> <Junit.version> 4.12 </junit.version> <commons-fileupload.version> 1.3.1 </commons-fileupload.version> <druid.version> 1.0.13 </druid.version> <jstl.version> 1.2 </jstl.version> <jsp-api.version> 2.0 </jsp-api.version> <jackson.version> 2.9.2 </ jackson.version> </properties> <dépendants> <! - 数据连接池 -> <dépendance> <GroupId> com.alibaba </proupId> <ArtefactId> Druid </Retifactid> <De version> $ {druid.version} </-groupID> </ Dependency> <Dedency> <ProupId> Commons Beanutiles </prouprid> <Artifactid> Commons-Beanutils </ ArtifactId> <version> $ {Commons.banutiles} </Dependency> <! - Spring-core -> <dependency> <proupId> org.springframework </proncId> <Ertifactid> printemps-core </ artifactId> <Dersion> $ {Spring.Version} </ version> </Dependency> <! - Spring-Context -> <Dedency> <ProupId> Org.SpringFramework </proupled> <ArtefactId> Spring-Context </ artifactid> <DERSE> $ {printemps.version} </ version> </ Dependency> <! - Spring AOP -> <Dedency> <proupId> org.springFramework </proupId> <Artefactive> Spring-AOP </ artifactid> <version> $ {Spring.Version} </Dursion> <Dedency> <! <dependency> <proupId> org.AspectJ </proupId> <Ertifactid> AspectJrt </RetifActid> <Dersion> $ {aspectj.version} </-version> </dependency> <! - Aspectj Weaver -> <Dedency> <ProupId> org.Aspectj </prouprid> <Artifactid> AspectJwweaver <version> $ {aspectj.weaver} </ version> </ dépendance> <! - Spring JDBC 的支持 -> <Dedency> <ProupID> org.springFramework </proncId> <ArtefactId> printemps-jdbc </ artifactId> <version> $ {printemps.version} </ version> </dependency> <! <GroupId> org.springFramework </proncId> <Artifactid> printemps-webmvc </ artifactid> <version> $ {printemps.fursion} </-version> </dependency> <! - Mybatis-Spring 整合 -> <dependency> <proupId> org.mybatis </prounid> <artifactid> mybatis-spring </ artifactive> <version> $ {mybatis.spring.version} </ version> </ dépendance> <! - Jackson Json 处理工具包 -> <dependency> <proupId> com.fasterxml.jackson.core </proupId> <Artifactid> jackson-databind </ artifactid> <version> {jackson.version} </De version> <dependency> <proupId> org.mybatis </rompuprid> <letifactive> mybatis </ artifactid> <version> $ {mybatis.version} </ version> </dependency> <! - MySql -> <dependency> <proupId> MySQL </prounid> <ArtifActid> Mysql-Connector-Java </proufact> <ArtifActid> Mysql-Connector-Java-Java </ Artiford> <version> $ {mysql.version} </-version> </ dépendance> <! - 文件上传组件 -> <dependency> <proupId> Commons-fileupload </proupId> <ArtifActid> Comons-fileupload </ Artifactid> <version> $ {commons-fileupload.Version} </De version> </Dedency> <! - JSP 相关 -> <dedence> <GroupId> JSTL </ GroupId> <Artifactid> JSTL </ ArfactId> <Dersion> $ {jstl.version} </ version> </ Dependency> <Dendency> <ProupID> Javax.servlet </prouprid> <Ertifactid> JSP-API </ Artifactid> <version> {jsp-api.version} </ version> <ccope> Fourni </cope> </ Dependency> <! - Test Dependues -> <Dependency> <ProupId> JUnit </rolgleId> <Artifactid> JUnit </ Artifactid> <Dersion> $ {Junit.Version} </ Version> <ccope> Test </ Scope> </Dependency> </Dependants> <Build> <DefaultGoal> Install </catedGoal> </Dependency> </Depends> <Build> <DefaultGoal> INTERTATION </ DAPPOTYGOLAL> <proupId> org.apache.maven.plugins </rompupid> <lefactive> maven-compiler-plugin </ artifactid> <DERVIRED> 3.6.1 </ version> </ configuration> <source> 1.8 </ource> <parget> 1.8 </ target> </ configuration> </gingin> <plugin> <proudId> Org.apache.maven.plugins </varin> <poulid> Org.apache.maven.plugins </ plugin> <ArtefactId> Maven-Resources-Plugin </ ArfactId> <Dersion> 3.0.2 </DERNIFRIGATION> <FIFIGIFICATION> <CODING> UTF-8 </coding> </FIGIGURATION> </ Plugin> </Glugins> <! - IDEA 编译 SRC 的 Java 文件 , 而目录下的 xml 文件并不会一起打包 , 需要手动指定哪些配置文件需要读取 -> <essravés> <Arnutory> SRC / Main / Java </ Directory> <clustred> <clut> ** / *. XML </rupture> </cluns> </ Resource> </ Resources> </Duild>1.2 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" 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"> <splay-nom <filter-name> CaractorEncoding </ Filter-Name> <Filter-Class> org.springframework.web.filter.characterencodingfilter </filter-class> <Init-Param> <param-name> Encoding </onsam-name> <param-Value> utf-8 </ param-Value> </1nit-Param> <param-name> Forceencoding </ param-name> <param-value> true </ param-value> </ init-param> </filter> <filter-mapping> <filter-name> CaractorEncoding </filter-name> <url-potern> / * </ url-potern> </filter-mapping> <! - // fin 编码过滤器 -> <!要用 _Method 指定真正的请求参数 -> <filter> <Filter-Name> httpMethodFilter </filter-Name> <Filter-Class> org.springframework.web.filter.httputformContentFilter </filter-classhodfilter </filter> <filtre> HTTPMETHODFILTER </ Filter> <Filter-name> HTTPMETHODFILTER </ Filter> <Imal-Name> HTTPMETHODFILTER </ Filter-named> <Url-Pattern> / * </ url-Pattern> </ Filter-Mapping> <filter> <Imter-Name> HiddenHttpMethodFilter </ Filter-Name> <HidDenddenhttpMethodFilter </filter-class> <filter-name> HiddenHttpMethodFilter </ Filter-name> <Url-Pattern> / * </rll-Pattern> </ Filter-Mapping> <! - Springmvc -> <Serplet> <Servlet-Name> Springmvc </ Servlet-Name> <Servlet-Class> org.springframework.web.wissert <Innit-Param> <Am param-name> ContextConfiglocation </ Param-Name> <AmArd-Value> ClassPath: Springmvc.xml </ Param-Value> </ Init-Param> <LoEnd-on-Startup> 1 </ Load-on-Startup> </vrlet> <Serplet-Mapping> <Serplet-Name> Springmvc </Serplet-Name> <Url-Pattern> *. shtml </url-Pattern> </ Servlet-Mapping> <! - // end printempsmvc -> <welcome-file-list> <leen welcome> index.shtml </ bienvenue-file> <ven welcome-file> index.htm </ bienvenue-file> </venue-file> index.jsp </kenge-file> <bienvenue> <Lelcome-File> Default.htm </ Welcome-File> <Eloyal-File> Default.jsp </venke-file> </ Welcome-File-list> </ web-app>
1.3 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: p = "http://www.springframework.org/schema/p" xmlns: context = "http://www.springframework.org/schema/contex XSI: ScheMalocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <! <Context: Component-Scan Base-Package = "CN.itcast" /> <! - 视图解析器配置 -> <anEn> <propriété name = "Prefix" value = "/ web-inf / jsp /" /> <propriété name = "suffix" value = ". Jsp" /> </ bean> <! - 文件上传解析器 -> <bean id = "multipartreSolver"> <! name = "maxuploadsize" value = "100000000" /> </ bean> <! - 引入 Spring 配置 -> <importation rourcecy = "spring.xml" /> </bans>
1.4 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: p = "http://www.springframework.org/schema/p" xmlns: context = "http://www.springframework.org/schema/contex xmlns: tx = "http://www.springframework.org/schema/tx" xmlns: aop = "http://www.springframework.org/schema/aop" xsi: schemalation = "http://www.spring http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd "> <! <Context: propriété-placeholder location = "classPath: jdbc.properties" /> <! - Les conseils transactionnels (ce qui se passe '; voir le <aop: conseiller /> bean ci-dessous) 事务传播特性配置 -> <tx: conseils id = "txadvice" transaction-manager = "txmanager"> <! - La méthode transactionnelle ... -> <tx: attaque> propagation = "obligatoire" isolation = "default" rollback-for = "java.lang.exception" /> <tx: méthode name = "enregistre *" propagation = "requise" isolation = "default" rollback-for = "java.lang.exception" /> <tx: méthode name = "insert *" propagation = "requise" isolation = "default" rollback <tx: méthode name = "update *" propagation = "requis" isolation = "default" rollback-for = "java.lang.exception" /> <tx: méthode name = "modifier *" propagation = "requise" isolation = "default" rollback-for = "java.lang.exception" /> <tx: méthode name = "delete *" propagation = "requis" requise " rollback-for = "java.lang.exception" /> <! - 查询方法 -> <tx: méthode name = "query *" read-only = "true" /> <tx: méthode name = "select *" read-only = "true" /> <tx: méthode name = "find *" readly = "true" /> </ tx: attributs> </tx: conseils> <! id = "txManager"> <propriété name = "dataSource" ref = "dataSource" /> </-bean> <! - 数据库基本信息配置 -> <bean id = "dataSource" init-méthod = "init" destrement-méthod = "close"> <propriété name = "driverclassname" value = "$ {jdbc.driver}" /> <propriété name = "url" Value = "$ {jdbc.url}" /> <propriété name = "username" value = "$ {jdbc.username}" /> <propriété name = "passway" value = "$ {jdbc.pwd}" /> </ bean> <! - 声明式事务 aop 配置 -> <aop: config> <aop: Pointcut expression = "exécution (* * * * cn.itcast.service.impl. *. * (..)) "id =" Tranpointcut "/> <aop: conseiller conseils-ref =" txadvice "Pointcut-ref =" TranpointCut "/> </ aop: config> <! MyBatis 配置文件 MyBatis 配置映射文件 指定数据源 -> <propriété name = "TYPEALIASESPACKAGE" Value = "cn.itcast.model" /> <propriété name = "ConfigLocation" value = "classpath: mybatis.xml" /> <property name = "MapperLocations"> <Array> <Value> ClassPath: CN / Itcast / MAPPER </ propriété> <propriété name = "dataSource" ref = "dataSource" /> </ bean> <! - 包扫描 -> <bean id = "mapscannerconfigurer"> <! - 指定对应接口的包路径 -> <propriété name = "basepackage" value = "cn.itcast.mapper" /> <propriété name = "sqlSessionfactorybeanname" value = "sqlsessionfact </bEAN> </EANS>1.5 JDBC 配置文件
jdbc.driver = com.mysql.jdbc.Driverjdbc.url = jdbc: mysql: //127.0.0.1: 3306 / crm? useunicode = true & caractères odorjdbc.pwd = 123456
1.6 log4j 配置文件
log4j.rootlogger = debug, a1log4j.logger.com.taotao = debuglog4j.logger.org.mybatis = Debuglog4j.appender.a1 = org.apache.log4j.consoleAppenderLog4j.appender.a1.layout = org.apache.log4j.patternlayoutlog4j.appender.a1.layout.conversionpattern =% - d {% t] [% c] - [% p]% m% n1.7 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> </mure>
以上这篇 SSM 整合的配合文件 (分享) 就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持武林网。