maven+spring+springmvc+mybatis(oracle)环境配置

maven+spring+springmvc+mybatis(oracle)环境配置

配置环境总会遇到这样那样的问题,记录过程方便自己也方便遇到同样问题的IT人士

  1. pom.xml中需要导入的包,主要包括spring核心库,mabatis依赖,spring/mybatis依赖,oracle驱动依赖,dbcp用来在spring-mybatis.xml中配置数据库



  4.0.0

  com.katrina.webprojectdemo
  WebProjectDemo
  1.0-SNAPSHOT
  war

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

  
    UTF-8
    1.7
    1.7
    5.1.5.RELEASE

    
    3.2.2

    
    11.2.0

    
    1.7.18
    1.2.17
  

  
    
      junit
      junit
      4.11
      test
    
    
    
      org.springframework
      spring-core
      ${spring.version}
    
    
      org.springframework
      spring-web
      ${spring.version}
    
    
      org.springframework
      spring-oxm
      ${spring.version}
    
    
      org.springframework
      spring-tx
      ${spring.version}
    
    
      org.springframework
      spring-jdbc
      ${spring.version}
    
    
      org.springframework
      spring-webmvc
      ${spring.version}
    
    
      org.springframework
      spring-context
      ${spring.version}
    
    
      org.springframework
      spring-context-support
      ${spring.version}
    
    
      org.springframework
      spring-aop
      ${spring.version}
    

    
      org.springframework
      spring-test
      ${spring.version}
    

    
    
      org.mybatis
      mybatis
      ${mybatis.version}
    

    
    
      org.mybatis
      mybatis-spring
      1.3.0
    

    
    
      com.oracle
      ojdbc6
      ${oracle-driver.version}
    

    
    
      commons-dbcp
      commons-dbcp
      1.2.2
    

    
      log4j
      log4j
      ${log4j.version}
    

    
      org.mybatis.generator
      mybatis-generator-core
      1.3.5
    

    
      org.codehaus.jackson
      jackson-mapper-asl
      1.9.12
    

    
      org.codehaus.jackson
      jackson-core-asl
      1.9.12
    
  

  
    WebProjectDemo
    
      
        
          maven-clean-plugin
          3.1.0
        
        
        
          maven-resources-plugin
          3.0.2
        
        
          maven-compiler-plugin
          3.8.0
        
        
          maven-surefire-plugin
          2.22.1
        
        
          maven-war-plugin
          3.2.2
        
        
          maven-install-plugin
          2.5.2
        
        
          maven-deploy-plugin
          2.8.2
        

      
    

    
      
      
        org.mybatis.generator
        mybatis-generator-maven-plugin
        1.3.5
        
          src/main/resources/mybatis-generator/generatorConfig.xml
          true
          true
        
        
          
            Generate MyBatis Artifacts
            
              generate
            
          
        
        
          
          com.oracle
          ojdbc6
          ${oracle-driver.version}
          runtime
          

          
            org.mybatis.generator
            mybatis-generator-core
            1.3.5
          
        
      
    


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





  1. 需要的配置文件web.xml,spring-mvc.xml,spring-mybatis.xml,jdbc-properties
    maven+spring+springmvc+mybatis(oracle)环境配置_第1张图片

  2. web.xml主要包含上下文,spring监听器,编码过滤器,springmvc的DispatherServlet





  Archetype Created Web Application

  
    contextConfigLocation
    classpath:application/spring-mybatis.xml
  


  
  
    
      org.springframework.web.context.ContextLoaderListener
    
  
  
  
    encodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    
      encoding
      UTF-8
    
    
      forceEncoding
      true
    
  
  
    encodingFilter
    /*
  
  
  
    
      org.springframework.web.util.IntrospectorCleanupListener
    
  

  
  
    SpringMVC
    
      org.springframework.web.servlet.DispatcherServlet
    
    
      contextConfigLocation
      classpath:application/spring-mvc.xml
    
    1
    
  
  
    SpringMVC
    
    *.do
  

  
    index.jsp
  

  
  
    20
  



3.spring-mybatis.xml





    

    
        
    

    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    

    
        
        
    

    
    
        
        
    

    
    
        
    
    
    


4.jdbc.properties

#连接oracle数据库
driverClassName=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@192.168.2.102:1521:agriculture
username=katrina
password=katrina
#定义初始连接数
initialSize=0
#定义最大连接数
maxActive=20
#定义最大空闲
maxIdle=20
#定义最小空闲
minIdle=1
#定义最长等待时间
maxWait=60000

5.spring-mvc.xml




    
    
    


    
    
    

    
    
        
        
        
    


    



你可能感兴趣的:(springmvc)