Java code for building springmvcmybatis project structure in WeChat development

Source: Internet
Author: User
This article mainly introduces in detail the second step of development preparation. springmvc and mybatis project construction have some reference value, interested friends can refer to this article for details on the second step of development preparation. the establishment of springmvc and mybatis project structures has some reference value, for more information, see

The previous article explains how to build a maven project in MyEclipse. here we will continue to introduce SpringMVC, a common javaweb framework, to the basic maven project!

① Introduce the dependency to the pom. xml file in the established maven project. the code is as follows:

  
  
   
4.0.0
   
  
   
Wechat.cuiyongzhi.com
  Wechat 
  
   
War
   
  
   
0.0.1-SNAPSHOT
   
  
   
Wechat
   
  
   
Http://maven.apache.org </url>
     
      
       
     
      
Org. springframework
     Spring-test   
     
      
3.2.0.RELEASE
       
      
       
     
      
Org. springframework
     Spring-webmvc   
     
      
3.2.0.RELEASE
       
      
       
     
      
Org. springframework
     Spring-core   
     
      
3.2.0.RELEASE
       
       
      
       
     
      
Org. mybatis
     Mybatis   
     
      
3.1.1
       
      
       
     
      
Org. mybatis
     Mybatis-spring   
     
      
1.1.1
       
       
      
       
     
      
Mysql
     Mysql-connector-java   
     
      
5.1.21
       
       
      
       
     
      
Junit
     Junit   
     
      
4.11
        
     
      
Test
       
       
      
       
     
      
Com. alibaba
     Druid   
     
      
0.2.9
       
       
      
       
     
      
Org. aspectj
     Aspectjweaver   
     
      
1.7.1
       
       
      
       
     
      
Com. alibaba
     Fastjson   
     
      
1.2.7
       
       
      
       
     
      
Commons-fileupload
     Commons-fileupload   
     
      
1.2.2
       
       
      
       
     
      
Javax. servlet
     Servlet-api   
     
      
3.0-alpha-1
       
       
       
     
      
Javax. servlet. jsp
     Jsp-api   
     
      
2.1
        
     
      
Provided
       
       
       
     
      
Javax. servlet
     Jstl   
     
      
1.2
       
       
      
       
     
      
Log4j
     Log4j   
     
      
1.2.17
       
     
    
     
    
     
Wechat
     
   
  
 

② Modify the web. xml file in the project path as follows:

 
  
  
   
Com. cuiyongzhi. wechat
   
    
   
    
ContextConfigLocation
     
   
    
Classpath: spring. xml, classpath: spring-mybatis.xml
     
    
   
    
   
    
Log4jConfigLocation
     
   
    
Classpath: log4j. properties
    
   
    
   
    
Org. springframework. web. util. Log4jConfigListener
    
   
    
   
    
Spring. profiles. active
     
   
    
Dev
    
   
    
   
    
Spring. profiles. default
     
   
    
Dev
    
   
    
   
    
Spring. liveBeansView. mbeanDomain
     
   
    
Dev
    
   
    
   
    
EncodingFilter
     
   
    
Org. springframework. web. filter. CharacterEncodingFilter
     
      
    
     
Encoding
       
    
     
UTF-8
      
     
      
    
     
ForceEncoding
       
    
     
True
      
    
   
    
   
    
Spring listener
     
   
    
Org. springframework. web. context. ContextLoaderListener
    
   
   
    
   
    
Org. springframework. web. util. IntrospectorCleanupListener
    
   
    
   
    
Spring mvc servlet
     
   
    
SpringMvc
     
   
    
Org. springframework. web. servlet. DispatcherServlet
     
      
    
     
Spring mvc configuration file
       
    
     
ContextConfigLocation
       
    
     
Classpath: spring-mvc.xml
      
     
   
    
1
    
   
    
   
    
Interface_url-init_servlet
     
   
    
Com. cuiyongzhi. web. start. InterfaceUrlIntiServlet
     
   
    
1
    
   
    
   
    
SpringMvc
     
   
    
/
    
    
    
   
    
/Index. jsp
    
   
    
   
    
300
    
    
    
   
    
404
     
   
    
// WEB-INF/error. jsp
    
    
    
   
    
500
     
   
    
// WEB-INF/error. jsp
    
    
    
   
    
Default
     
   
    
*. Css
    
    
    
   
    
Default
     
   
    
*. Gif
    
    
    
   
    
Default
     
   
    
*. Jpg
    
    
    
   
    
Default
     
   
    
*. Js
    
    
    
   
    
Default
     
   
    
*. Xhtml
    
    
    
   
    
Default
     
   
    
*. Html
    
    
    
   
    
DruidWebStatFilter
     
   
    
Com. alibaba. druid. support. http. WebStatFilter
     
      
    
     
Exclusions
       
    
     
*. Js, *. gif, *. jpg, *. png, *. css, *. ico,/druid /*
      
    
   
    
   
    
DruidWebStatFilter
     
   
    
/*
    
   
    
   
    
DruidStatView
     
   
    
Com. alibaba. druid. support. http. StatViewServlet
     
      
       
    
     
ResetEnable
       
    
     
True
      
     
      
       
    
     
LoginUsername
       
    
     
Cuiyongzhi
      
     
      
       
    
     
LoginPassword
       
    
     
123456
      
    
   
    
   
    
DruidStatView
     
   
    
/Druid /*
    
   
    
    
      
    
     
JspConfiguration
       
    
     
*. Jsp
       
    
     
False
       
    
     
False
       
    
     
/WEB-INF/common/head. jsp
      
    
   
 

③ Add the database configuration information. here, the project configuration database is MySQL, and the config. properties configuration file is created under resources. The settings are as follows:

validationQuery=SELECT 1jdbc_url=jdbc:mysql://127.0.0.1:3306/wechat?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNulljdbc_username=root jdbc_password=123456789

④ Create a spring. xml configuration file under resources and set it as follows:

 
  
   
   
   
   
     
 

⑤ Create a spring-mvc.xml profile under resources and set it as follows:

 
   
   
    
   
    
      
        
     
      
Text/html; charsets = UTF-8
        
      
    
    
   
    
      
        
     
        
      
    
    
   
    
    
      
    
     
UTF-8
      
     
      
    
     
32505856
    
      
     
      
    
     
4096
      
    
    
 

⑥ Create a spring-mybatis.xml profile under resources with the following settings:

 
   
   
    
     
     
      
     
     
     
     
     
     
     
     
     
      
     
       
     
     
     
      
     
     
     
      
     
     
     
     
     
      
     
     
    
    
   
    
     
     
    
    
    
     
    
    
   
    
    
    
   
    
   
    
      
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      
    
           
   
   
   
    
      
        
     
      
Com. cuiyongzhi. web. service .*
        
      
    
       
 

7. create a log4j. properties configuration file under resources to set the log output level and output position. The settings are as follows:

This article mainly focuses on code examples. The basic project establishment is recorded here. in the next article, I will briefly describe some simple applications under this framework. thank you for reading this article. if you have any questions, you can discuss it!

The above is the detailed description of java code built in springmvc mybatis project structure. For more information, see other related articles on php Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.