SSM+Maven+MySQL 搭建 (IDEA2018)

1.搭建环境: IDEA2018 + JDK1.8 + Tomcat9 + MySQL

项目地址(FREE):https://download.csdn.net/download/qq_36474549/10731823

2.Maven 依赖 pom.xml





    4.0.0
    war

    TestMaven
    com.wz
    TestMaven
    1.0-SNAPSHOT

    
        
            
                src/main/java
                
                
                    **/*.xml
                
            
            
            
                src/main/resources
            
        

        
            
                org.mortbay.jetty
                maven-jetty-plugin
                6.1.7
                
                    
                        
                            8888
                            30000
                        
                    
                    ${project.build.directory}/${pom.artifactId}-${pom.version}
                    
                    /
                
            
            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.5
                
                    1.8
                    1.8
                    UTF-8
                
            
        

    

    
    
        4.3.14.RELEASE
        3.4.6
        1.7.12
        1.2.17
    
    
    


        
        
            javax
            javaee-api
            8.0
        
        
            javax.activation
            activation
            1.1.1
        

        
        
        
            org.projectlombok
            lombok
            1.16.18
        
        

        
        
            junit
            junit
            4.11
            
            test
        

        
        
            org.springframework
            spring-test
            ${srping.version}
        
        
            org.springframework
            spring-core
            ${srping.version}
        
        
            org.springframework
            spring-oxm
            ${srping.version}
        
        
            org.springframework
            spring-tx
            ${srping.version}
        
        
            org.springframework
            spring-jdbc
            ${srping.version}
        
        
            org.springframework
            spring-aop
            ${srping.version}
        
        
            org.springframework
            spring-context
            ${srping.version}
        
        
            org.springframework
            spring-context-support
            ${srping.version}
        
        
            org.springframework
            spring-expression
            ${srping.version}
        
        
            org.springframework
            spring-orm
            ${srping.version}
        
        
            org.springframework
            spring-web
            ${srping.version}
        
        
            org.springframework
            spring-webmvc
            ${srping.version}
        
        

        
        
            org.mybatis
            mybatis
            ${mybatis.version}
        
        
            org.mybatis
            mybatis-spring
            1.3.2
        
        

               
         
            mysql
            mysql-connector-java
            5.1.35
        
        
            com.alibaba
            druid
            1.0.9
        
         
    
        
        
            jstl
            jstl
            1.2
        

        
        
            log4j
            log4j
            ${log4j.version}
        
        
            org.slf4j
            slf4j-api
            ${slf4j.version}
        
        
            org.slf4j
            slf4j-log4j12
            ${slf4j.version}
        
        

        
        
        
            com.alibaba
            fastjson
            1.2.6
        
        
            org.codehaus.jackson
            jackson-mapper-asl
            1.9.13
        
        

        
        
            commons-fileupload
            commons-fileupload
            1.3.1
        
        
            commons-io
            commons-io
            2.4
        
        
            commons-codec
            commons-codec
            1.10
        
        

    
  

3.全局配置 web.xml




  TestMaven


  
  
    org.springframework.web.context.ContextLoaderListener
  
  
  
    contextConfigLocation
    classpath:applicationContext-*.xml
  

  
  
    org.springframework.web.util.IntrospectorCleanupListener
  

  
  
    SpringMVC
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      classpath:springmvc.xml
    
    1
    true
  
  
    SpringMVC
    
    /
  

  
  
    encodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    true
    
      encoding
      UTF-8
    
  
  
    encodingFilter
    /*
  

  
    /jsp/itemList.jsp
  


4.spring相关配置

      a. 资源加载扫描配置 applicationContext-source.xml




	
	


	
	

	
	
		
		
		
		
	


             b.spring全局基本配置:applicationContext-dao.xml




    
        
        
        
        
        
        

    

    
    
        
        
        
        
        
        
        
        
    


           c.spring服务配置:applictionContext-service.xml





            d.spring事务配置:applicationContext-trans.xml




    
    
        
        
    

    
    

5.资源文件配置

             a.jdbc.properties

jdbc_driver=com.mysql.jdbc.Driver
jdbc_url=jdbc:mysql://localhost:3306/springmvc?useUnicode=true&characterEncoding=UTF-8
jdbc_username=root
jdbc_password=root

             b.log4j.properties

# Global logging configuration
#在开发环境下日志级别要设置成DEBUG,生产环境设置成info或error
log4j.rootLogger=info,console,FILE

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.threshold=info
log4j.appender.console.layout=org.apache.log4j.PatternLayout  
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] -%F(%L) -%m%n  

6.前端itemLIst.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>




查询商品列表

 
查询条件:
商品列表:
商品名称 商品价格 生产日期 商品描述 操作
${item.name } ${item.price } ${item.detail } 修改

7.项目bean与mapper部分由逆向工程生成

8.项目结构

SSM+Maven+MySQL 搭建 (IDEA2018)_第1张图片

你可能感兴趣的:(SSM,IDEA)