SpringBoot process integration SpringMVC, Mybatis build a web-based project

  1. Create a new maven project, whether webapp, quickstart can, as long as the directory structure intact can be.
    a) Directory Structure
    Here Insert Picture Description

  2. Springboot need to integrate springmvc, mybatis framework, as well as its own configuration. Therefore, the need to add the appropriate dependencies pom file
    a) introducing into a parent pom

    org.springframework.boot
    Spring-Boot-Starter-parent
    1.5.9.RELEASE

    B) to be introduced into the web springmvc integration start dependent

    org.springframework.boot
    Spring-Boot Web--starter

    C) integrated to import dependent mybatis org.springframework.boot Spring-Boot-Starter-JDBC MySQL MySQL Java-Connector- org.mybatis.spring.boot mybatis-Spring-Boot-Starter 1.3.0















  3. After the integration of the three framework does not represent the required dependencies have been imported, it must also import some other dependencies necessary depending on the function required.
    a) Springboot dependent jsp support of the javax.servlet the javax.servlet-API the javax.servlet JSTL org.apache.tomcat.embed tomcat-Jasper the embed- 7.0.59 B) deployed to project on the Tomcat I. tomcat introduced dependence, and exclusion springboot conflict built container org.springframework.boot springboot-Starter-Tomcat Provided II. pom modify the file type of packaging WAR WAR III. modifications inlet class tagging @ServletComponentScan annotation on the inlet by the class, and make these Inheritance SpringBootServletInitializer.



























    iv.	如果打好的war在tomcat中启动后提示convert错误,说明缺少jackson包,手动导入依赖即可
    	<!-- 导入jackson依赖 -->
    	<dependency>
    		<groupId>com.fasterxml.jackson.core</groupId>
    		<artifactId>jackson-annotations</artifactId>
    	</dependency>
    	<dependency>
    		<groupId>com.fasterxml.jackson.core</groupId>
    		<artifactId>jackson-core</artifactId>
    	</dependency>
    
  4. Springboot profile application.properties
    # Set Tomcat port, default 8080
    server.port = 8080

    # Database driver name
    spring.datasource.dirver-class-name = com.mysql.jdbc.Driver
    # database address
    spring.datasource.url = jdbc: MySQL: /// springbootdb
    # database user name
    spring.datasource.username = root
    # database password
    spring.datasource.password = root

    #mybatis mapping file location
    mybatis.mapperLocations = the CLASSPATH:. Mapper / xml *
    # configuration mapping file the return path type of
    mybatis.typeAliasesPackage = cn.tedu.domain
    # whether to enable hump naming
    mybatis.configuration.mapUnderscoreToCamelCase = true

    # Resolver configuration view
    spring.mvc.view.prefix = / the WEB-INF / JSP /
    spring.mvc.view.suffix = .jsp

Published an original article · won praise 0 · Views 7

Guess you like

Origin blog.csdn.net/weixin_43328735/article/details/104822348