1.1 Maven 项目 Pom 管理
<!-常量和版本号-> <properties> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <project.roporting.outputEncoding> utf-8 </project.Reporting.UtputEncoding> <pring.version> 4.3.2.release </spring.version> <pisitionsj.version> 1.8.6 </aspectj.version> <pectionj.weaver> 1.8.6 </aspectj.weaver> <mybatis.spring.version> 1.3.0 </mybatis.spring.spring <mybatis.version> 3.4.5 </mybatis.version> <mysql.version> 5.1.32 </mysql.version> <lf4j.version> 1.7.25 </slf4j.version> <lf4j.log4j12.version> 1.7.25 <log4j.version> 1.2.17 </log4j.version> <log4j.core.version> 2.3 </log4j.core.version> <mommons.logging.version> 1.2 </commons.logging.version> <junit.ersion> 4.12 </junit. <momons-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.api. <Jackson.Version> 2.9.2 </jackson.version> </premerties> <การพึ่งพา> <!-数据连接池-> <การพึ่งพา> <roupId> com.alibaba </groupid> <ratifactid> druid </artifactid> <ArtIfactId> Commons-Beanutils </artifactid> <sersion> $ {commons.beanutils} </version> </การพึ่งพา> <!-Spring-core-> <การพึ่งพาอาศัย> <roupid> org.springframework </groupid> Spring-Context-> <การพึ่งพา> <roupId> org.springFramework </groupId> <ratifactId> Spring-context </artifactid> <persion> $ {Spring.Version} </Servent> </การพึ่งพา> <!-Spring AOP-> <การพึ่งพา> <cerson> $ {spring.version} </version> </การพึ่งพา> <!-runtime appectj-> <cendency> <roupId> org.aspectj </groupId> <ratifactid> APSITIONSJRT </artifactId> <ArtIfactId> appectJweaver </artifactId> <persion> $ {appectj.weaver} </เวอร์ชัน> </การพึ่งพา> <!-ฤดูใบไม้ผลิ jdbc 的支持-> <cendency> <roupid> org.springframework </groupid> <!-SpringMvc-> <การพึ่งพา> <roupId> org.springframework </groupId> <ratifactId> Spring-Webmvc </artifactid> <sersion> $ {Spring.Version} </Side> </การพึ่งพา> <! <ArtifactId> mybatis-spring </artifactid> <persion> $ {mybatis.spring.version} </version> </perdency> <!-Jackson Json 处理工具包-> <cendency> <Sersion> $ {Jackson.Version} </Sident> </การพึ่งพาอาศัย> <!-myBatis-> <การพึ่งพา> <roupId> org.mybatis </groupId> <ratifactid> mybatis </artifactid> <cersion> $ {mybatis.version} <RoupID> mySQL </groupID> <TarTifactId> mysql-connector-java </artifactid> <sersion> $ {mysql.version} </version> </derpendency> <!-文件上传组件-> <predency> <Sersion> $ {Commons-FileUpload.Version} </เวอร์ชัน> </การพึ่งพา> <!-jsp 相关-> <การพึ่งพา> <roupId> jstl </groupId> <ratifactid> jstl </artifactid> <version> $ {jstl.ersion} <ArtIfactId> jsp-api </artifactId> <persion> $ {jsp-api.version} </เวอร์ชัน> <pope> ให้ </scope> </predency> <!-ทดสอบการพึ่งพา-> <predency> <droupid> junit </groupid> <scope> ทดสอบ </cope> </derctency> </perctencies> <uffer> <deftiaggoal> ติดตั้ง </defaultGoal> <plugins> <plugin> <loupid> org.apache.maven.plugins </roupid> <atifactid> maven-compiler-plugin </artifactid> <garget> 1.8 </source> </การกำหนดค่า> </plugin> <plugin> <slugin> <roupid> org.apache.maven.plugins </groupid> <ratifactid> maven-resources-plugin </artifactid> <version> 3.0.2 </เวอร์ชัน> <การกำหนดค่า> <!-ความคิด编译 src 的 java 文件, 而目录下的 xml 文件并不会一起打包, 需要手动指定哪些配置文件需要读取-> <resources> <sroves> <sresours> <ไดเรกทอรี> src/main/java </directory> <รวมถึง> <รวม> **/*. xml </include>1.2 web.xml 配置
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <web-app xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance" xmlns = "http://java.sun.com/xml XSI: schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id = "webapp_id" เวอร์ชัน = "3.0"> <Stilter-Name> การเข้ารหัส </filter-Name> <Tilter-CLASS> org.springframework.web.filter.characterencodingFilter </filter-class> <init-Param> <param-name> การเข้ารหัส </param-name> <param-name> forceencoding </param-name> <param-value> True </param-value> </itt-param> </filter> <ฟิลเตอร์-แม็พ> <filter-name> ตัวละคร </filter-name> <url-pattern>/*</url-pattern>要用 _Method 指定真正的请求参数-> <filter> <filter-name> httpmethodfilter </filter-name> <filter-class> org.springframework.web.filter.httpputformcontentfilter </filter-class> </filter> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name> hiddenhttpmethodfilter </filter-name> <Tilter-Name> HIDVERHTTPMETHODFILTER </filter-Name> <url-Pattern>/*</url-pattern> </filter-mapping> <!-springmvc-> <servlet> <int-Param> <param-Name> contextConfigLocation </param-name> <param-value> classpath: springmvc.xml </param-value> </init-param> <load-on-startup> 1 </load-on-startup> </servlet> <url-pattern>*. shtml </url-pattern> </servlet-mapping> <!-// สิ้นสุด SpringMvc-> <welcome-file-list> <welcome-file> index.shtml </welcome-file> <welcome-file> default.htm </welcome-file> <welcome-file> default.jsp </welcome-file> </welcome-file-list> </eb-app>
1.3 SpringMVC 配置文件
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://ww.w3.org/2001/xml xmlns: p = "http://www.springframework.org/schema/p" xmlns: บริบท = "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/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schemaem/mvc <บริบท: Component-Scan base-package = "cn.itcast"/> <!-视图解析器配置-> <bean> <property name = "คำนำหน้า" value = "/web-inf/jsp/"/> <property name = "suffix" value = ". jsp"/> </epean> <! name = "MaxUploadSize" value = "100000000"/> </ebean> <!-引入ฤดูใบไม้ผลิ配置-> <import Resource = "Spring.xml"/> </ebeans>
1.4 ฤดูใบไม้ผลิ配置文件
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://ww.w3.org/2001/xml xmlns: p = "http://www.springframework.org/schema/p" xmlns: บริบท = "http://www.springframework.org/schema/contex xmlns: tx = "http://www.springframework.org/schema/tx" xmlns: aop = "http://www.springframework.org/schema/aop" xsi: schemalocation = "http:/ http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/ttp http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/schema -> <บริบท: สถานที่ตั้งสถานที่ตั้งของสถานที่ = "classpath: jdbc.properties" /> <!-คำแนะนำการทำธุรกรรม (สิ่งที่ 'เกิดขึ้น'; ดู <aop: ที่ปรึกษา /> ถั่วด้านล่าง) 事务传播特性配置-> <tx: คำแนะนำ id = "txadvice" transaction-manager = "txmanager" การแพร่กระจาย = "จำเป็น" isolation = "default" rollback-for = "java.lang.exception" /> <tx: method name = "save*" การแพร่กระจาย = "ต้องการ" isolation = "default" rollback-for = "java.lang.exception" /> <tx <tx: method name = "update*" การแพร่กระจาย = "จำเป็น" isolation = "default" rollback-for = "java.lang.exception" /> <tx: method name = "Modify*" การแพร่กระจาย = "จำเป็น" isolation = "เริ่มต้น" RollBack-for = "java.lang.exception" /> <!-查询方法-> <tx: method name = "query*" read-only = "true" /> <tx: method name = "select*" read-only = "true" /> <tx: method = "find* id = "txManager"> <property name = "dataSource" ref = "dataSource" /> </ebean> <!-数据库基本信息配置-> <bean id = "dataSource" init-method = "init" destroy-method = "Close"> value = "$ {jdbc.url}" /> <property name = "username" value = "$ {jdbc.username}" /> <property name = "รหัสผ่าน" value = "$ {jdbc.pwd}" /> < /bean> <! cn.itcast.service.impl.*.*(.. )) "id =" tranpointcut " /> <aop: คำแนะนำที่ปรึกษา-ref =" txadvice "pointcut-ref =" tranpointcut " /> < /aop: config> <! myBatis 配置文件 mybatis 配置映射文件 -> <property name = "typealiasEspackage" value = "cn.itcast.model"/> <property name = "การกำหนดค่า" value = "classpath: mybatis.xml"/> <property name = "mapperlocations"> <rray> </คุณสมบัติ> <property name = "dataSource" ref = "dataSource"/> </ebean> <!-包扫描-> <bean id = "mapperscannerConfigurer"> <!-指定对应接口的包路径-> <property name = "basePackage" ค่า = "cn.itcast.mapper"/> </ebean> </ebeans>1.5 JDBC 配置文件
jdbc.driver = com.mysql.jdbc.driverjdbc.url = jdbc: mysql: //127.0.0.1: 3306/crm? useunicode = true & riblementencoding = utf8 & autoreconnect = truejdbc.username = rootjdbc.
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.layaUt.ConversionPattern =%-D [%c]-[%p]%m%n
1.7 MyBatis 配置文件
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <! doctype การกำหนดค่าสาธารณะ "-// mybatis.org//dtd config 3.0 // en" "http://mybatis.org/dtd/mybatis-3-config.dtd
以上这篇 SSM 整合的配合文件 (分享) 就是小编分享给大家的全部内容了, 希望能给大家一个参考, 也希望大家多多支持武林网。也希望大家多多支持武林网。