maven配置 ssm

1.在main目录下创建 java和resource目录

把java标记成Sources root
把resource 标记成 Resources root

pom文件




  4.0.0

  com
  ww
  1.0-SNAPSHOT
  war

  ww Maven Webapp
  
  http://www.example.com

  
    UTF-8
    1.7
    1.7
  

  

    
      junit
      junit
      4.11
      test
    


      
      
          aopalliance
          aopalliance
          1.0
      

      
      
          org.aspectj
          aspectjrt
          1.8.10
      

      
      
          commons-io
          commons-io
          2.6
      

      
      
          commons-fileupload
          commons-fileupload
          1.3.1
      

      
      
          commons-logging
          commons-logging
          1.2
      

      
      
          com.fasterxml.jackson.core
          jackson-core
          2.9.1
      

      
      
          com.fasterxml.jackson.core
          jackson-databind
          2.9.1
      

      
      
          com.fasterxml.jackson.core
          jackson-annotations
          2.9.0
      




      
      
          javax.servlet
          jstl
          1.2
      



      
      
          log4j
          log4j
          1.2.17
      

      

      
      
          org.springframework
          spring-aop
          4.3.6.RELEASE
      


      
      
          org.springframework
          spring-aspects
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-beans
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-context
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-context-support
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-core
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-expression
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-jdbc
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-tx
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-web
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-webmvc
          4.3.6.RELEASE
      

      
      
          org.springframework
          spring-orm
          4.3.6.RELEASE
      

      
      
          com.alibaba
          druid
          1.1.5
      

      
      
          org.mybatis
          mybatis
          3.4.1
      

      
      
          org.mybatis
          mybatis-spring
          1.3.0
      

      
      
          mysql
          mysql-connector-java
          5.1.45
      

  

  
    ww
    
      

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



        
          maven-clean-plugin
          3.0.0
        
        
        
          maven-resources-plugin
          3.0.2
        
        
          maven-compiler-plugin
          3.7.0
        
        
          maven-surefire-plugin
          2.20.1
        
        
          maven-war-plugin
          3.2.0
        
        
          maven-install-plugin
          2.5.2
        
        
          maven-deploy-plugin
          2.8.2
        


      

    
      

          
              org.apache.tomcat.maven
              tomcat7-maven-plugin
                2.2
              
                  80
                  /
                  UTF-8
                  tomcat7
              
          

          

              org.mybatis.generator

              mybatis-generator-maven-plugin

              1.3.5

          

      

      
          
              src/main/java
          
          
              src/main/resources
          
      
  



tomcat7无法更新到maven projects解决方法
新建一个plugin (与pluginManagement同级)

 

          
              org.apache.tomcat.maven
              tomcat7-maven-plugin
                2.2
              
                  80
                  /
                  UTF-8
                  tomcat7
              
          
      

mybatis生成工具

插件

    

              org.mybatis.generator

              mybatis-generator-maven-plugin

              1.3.5

          

配置文件

放在resource目录下名字一定要设置成generatorConfig.xml




    
  
  
    
  
    
   
    
   
   
    
         
         
    
   
   
    
        
    
   
   
    
   
                             

注意 targetProject="src/main/java"

目录结构

maven配置 ssm_第1张图片
image.png

web.xml






  
    contextConfigLocation
    classpath:/config/spring-application.xml
  

  
    org.springframework.web.context.ContextLoaderListener
  




  
    DispatcherServlet
    org.springframework.web.servlet.DispatcherServlet


    
      contextConfigLocation
      classpath:config/spring-mvc.xml
    

    1
  
  
    DispatcherServlet
    /
  
  
    characterEncodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    
      encoding
      UTF-8
    
    
      forceEncoding
      true
    
  
  
    characterEncodingFilter
    /*
  
  springmvc
  
    index.html
    index.htm
    index.jsp
    default.html
    default.htm
    default.jsp
  

  Archetype Created Web Application



mybaits-config.xml










spring-application.xml




    
    
    
        
        
      
    
    
    
        
        
        
        
    
    
        
            
    
    
    
    
        
        
    
    
      
    
    



spring-mvc.xml



    
            
                
                
                    
                    
                    
                        
                            text/html
                            text/plain
                            application/json
                        
                    
                
            
    
    
    
    
    
    
        
        
    
    
    
    
    

    
    
    
        
        
        
    
    
    
    
    
    
        
        
        
        
    
    
    
    
    



jdbc.properties

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/demo1
username=root
password=admin


log4j.properties


 ### 设置###
log4j.rootLogger = debug,stdout,D,E

### 输出信息到控制抬 ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n

### 输出DEBUG 级别以上的日志到=E://logs/error.log ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = E://logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG 
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

### 输出ERROR 级别以上的日志到=E://logs/error.log ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File =E://logs/error.log 
log4j.appender.E.Append = true
log4j.appender.E.Threshold = ERROR 
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n

log4j 需要使用log4j2 没有配置

你可能感兴趣的:(maven配置 ssm)