Maven工程配置SSM(Spring SpringMVC Mybatis)

Maven工程配置SSM(Spring SpringMVC Mybatis)_第1张图片

 

第一步:整合dao层(spring和mybatis整合,spring管理mapper接口,使用mapper的扫描器自动扫描mapper接口在spring中进行注册)

第二步:整合Service层(spring管理service接口,使用配置的方式将service配置到spring配置文件中,也可以使用注解的方式。实现事务控制)

第三步:整合springMVC(由于springMVC是spring的模块,不需要整合,只需要添加spring-mvc的包)

准备环境:

1.jdk1.8

2.所需jar包:

javax.servlet-api-4.0.1.jar

javax.servlet.jsp-api-2.0.jar

mysql-connector-java-5.1.39.jar

com.mchange-c3p0-0.9.5.2.jar

commons-pool-1.6.jar

commons-dbcp-1.4.jar

aopalliance-1.0.jar

asm-3.3.1.jar

org.springframework.spring-aspects-5.1.4.RELEASE.jar

aspectj.aspectjtools-1.5.0.jar

aspectj.aspectjweaver-1.5.3.jar

cglib.cglib-3.2.5.jar

commons-logging-1.1.1.jar

org.javassist.javassist-3.20.0-GA.jar

javax.servlet.jstl-1.2.jar

log4j-1.2.17.jar

org.apache.logging.log4j.log4j-api-2.11.1.jar

org.apache.logging.log4j.log4j-core-2.11.1.jar

org.mybatis.mybatis-3.4.6.jar

org.mybatis.mybatis-spring-1.3.2.jar

org.springframework.spring-aop-5.1.5.RELEASE.jar

org.springframework.spring-aspects-5.1.4.RELEASE.jar

org.springframework.spring-beans-5.1.3.RELEASE.jar

org.springframework.spring-context-5.1.3.RELEASE.jar

org.springframework.spring-context-support-5.1.5.RELEASE.jar

org.springframework.spring-core-5.1.5.RELEASE.jar

org.springframework.spring-expression-5.1.5.RELEASE.jar

org.springframework.spring-jdbc-5.1.5.RELEASE.jar

org.springframework.spring-orm-5.1.5.RELEASE.jar

org.springframework.spring-tx-5.1.5.RELEASE.jar

org.springframework.spring-test-5.1.1.RELEASE.jar

org.springframework.spring-web-5.1.5.RELEASE.jar

org.springframework.spring-webmvc-5.1.5.RELEASE.jar

org.codehaus.jackson.jackson-core-asl-1.9.13.jar

org.codehaus.jackson.jackson-mapper-asl-1.9.13.jar

3.其他jar包:

I/O   :   commons-io-2.4.jar

分页   :   com.github.pagehelper-4.1.6.jar

文件上传   :   commons-fileupload-1.3.3.jar

请求参数验证器:org.hibernate.hibernate-validator-6.0.13.Final.jar

                             org.jboss.logging.jboss-logging-3.3.0.Final.jar

                             javax.validation.validation-api-2.0.1.Final.jar

发送邮件:javax.mail-1.4.7.jar

                 javax.activation-1.1.1.jar

发送短信:commons-httpclient-3.1.jar

处理编码(MD5...):commons-codec-1.4.jar

解析xml:dom4j-1.6.1.jar

json:com.alibaba.fastjson-1.2.47.jar

maven工程引入jar包:


    
      junit
      junit
      3.8.1
      test
    
    
    
	
	    javax.servlet
	    javax.servlet-api
	    4.0.1
	    provided
	
	
	
	
	    javax.servlet
	    jsp-api
	    2.0
	    provided
	
	
	
	
	    mysql
	    mysql-connector-java
	    5.1.39
	

	
	
	    com.mchange
	    c3p0
	    0.9.5.2
	
	
	
	
	    commons-pool
	    commons-pool
	    1.6
	

	
	
	    commons-dbcp
	    commons-dbcp
	    1.4
	
	
	
	
	    aopalliance
	    aopalliance
	    1.0
	
	
	
	
	    asm
	    asm
	    3.3.1
	
	
	
	
	    org.springframework
	    spring-aspects
	    5.1.4.RELEASE
	

	
	
	    aspectj
	    aspectjtools
	    1.5.0
	
	
	
	
	    aspectj
	    aspectjweaver
	    1.5.3
	
	
	
	
	    cglib
	    cglib
	    3.2.5
	
	
	
	
	    commons-logging
	    commons-logging
	    1.1.1
	
	
	
	
	    org.javassist
	    javassist
	    3.20.0-GA
	
	
	
	
	    javax.servlet
	    jstl
	    1.2
	
	
	
	
	    log4j
	    log4j
	    1.2.17
	
	
	
	
	    org.apache.logging.log4j
	    log4j-api
	    2.11.1
	
	
	
	
	    org.apache.logging.log4j
	    log4j-core
	    2.11.1
	
	
	
	
	    org.mybatis
	    mybatis
	    3.4.6
	
	
	
	
	    org.mybatis
	    mybatis-spring
	    1.3.2
	
	
	
	
	    org.springframework
	    spring-aop
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-aspects
	    5.1.4.RELEASE
	

    
	
	    org.springframework
	    spring-beans
	    5.1.3.RELEASE
	
	
	    
	
	    org.springframework
	    spring-context
	    5.1.3.RELEASE
	
	
	
	
	    org.springframework
	    spring-context-support
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-core
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-expression
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-jdbc
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-orm
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-tx
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-test
	    5.1.1.RELEASE
	    test
	
	
	
	
	    org.springframework
	    spring-web
	    5.1.5.RELEASE
	
	
	
	
	    org.springframework
	    spring-webmvc
	    5.1.5.RELEASE
	
	
	
	
	
	    com.github.pagehelper
	    pagehelper
	    4.1.6
	
	
	
	
	    commons-fileupload
	    commons-fileupload
	    1.3.3
	
	
	
	
	    org.hibernate
	    hibernate-validator
	    6.0.13.Final
	
	
	
	
	    org.jboss.logging
	    jboss-logging
	    3.3.0.Final
	
	
	
	
	    javax.validation
	    validation-api
	    2.0.1.Final
	
	
	
	
	    javax.mail
	    mail
	    1.4.7
	

	
	
	    javax.activation
	    activation
	    1.1.1
	
	
	
	
	    commons-httpclient
	    commons-httpclient
	    3.1
	
	
	
	
	    commons-codec
	    commons-codec
	    1.4
	
	
	
	
	    dom4j
	    dom4j
	    1.6.1
	
	
	
	
	    com.alibaba
	    fastjson
	    1.2.47
	
	
	
	
	    org.codehaus.jackson
	    jackson-core-asl
	    1.9.13
	

	
	
	    org.codehaus.jackson
	    jackson-mapper-asl
	    1.9.13
	
	
  

 

配置完成的项目工程:

Maven工程配置SSM(Spring SpringMVC Mybatis)_第2张图片

sqlMapConfig.xml:



  

	
	
		
			
			
		
	

 

applicationContext-dao.xml:


 
		 
		
	
	
	
	
	
	
	
		
		
		
		
	
	
	
	
		
		
		
		
	
	
	
	
		
		
		
	

 

applicationContext-transaction.xml:


 
	
	
	
		
		
	
	
	

	

 

springmvc.xml:


   
	
	 
	
	
	

	
	
		
		
	
    

 

db.properties:

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssmproperties
jdbc.username=root
jdbc.password=a

log4j.properties:

log4j.rootLogger=DEBUG, stdout

log4j.logger.com.yc=TRACE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.patternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

web.xml:



  ssmProperties
  
  
  
  	contextConfigLocation
  	/WEB-INF/classes/spring/applicationContext-*.xml
  
  
  	org.springframework.web.context.ContextLoaderListener
  
  
  
  
  
  	springmvc
  	org.springframework.web.servlet.DispatcherServlet
  	
  	
  		contextConfigLocation
  		classpath:spring/springmvc.xml
  	
  	
  	 1
  
  
  	springmvc
  	
  	*.action
  
  
  
  
  	springmvc_rest
  	org.springframework.web.servlet.DispatcherServlet
  	
  		contextConfigLocation
  		classpath:spring/springmvc.xml
  	
  
  
  	springmvc_rest
  	/
  
  
  
  
    index.html
    index.htm
    index.jsp
    default.html
    default.htm
    default.jsp
  

pom.xml:

设置字符集:


  
  	
  	UTF-8
	UTF-8
  

设置JDK版本:

  
             org.apache.maven.plugins  
             maven-compiler-plugin  
               
                 1.8  
                 1.8  
               
          

配置jetty服务器:


			
				org.eclipse.jetty
				jetty-maven-plugin
				9.4.15.v20190215
				
					
						80
					
					
					2
					
					manual
					
					/
				
			 

 

你可能感兴趣的:(JavaWeb,工具,maven)