Spring boot + mybatis + jsp + maven hot deployment of Structures

1. Check the dependence

Here Insert Picture Description

2. The introduction of the jar package jsp

<!--tomcat 的jar -->
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
    <version>8.5.11</version>
    <!--
    <version>9.0.1</version>
    -->
</dependency>
<!--jsp 的jar -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

3. Build webapp directory

3.1. Creating webapp

Here Insert Picture Description Here Insert Picture Description

4. The configuration of the association

The first step, press F4 to open the configuration
Here Insert Picture DescriptionStep Two:
Here Insert Picture DescriptionThe third step:
Here Insert Picture Description
Step Four
Here Insert Picture Description

5.Application.properties configuration

server.port=8080
######配置jsp的视图解析其
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp



spring.datasource.url=jdbc:mysql://localhost:3306/wthink?setUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.initialSize=5
spring.datasource.minIdle=5
spring.datasource.maxActive=20
spring.datasource.maxWait=60000



#mapper 扫描xml文件
mybatis.mapper-locations=classpath:com/wthink/day703/dao/*Mapper.xml
mybatis.type-aliases-package=com.wthink.day703.dao

Red marked path where you need to create a project consistent with

The method 6.main configuration mybatis scanner

Here Insert Picture DescriptionWhy I obviously have mapper.xml project file, but after compiling system, mapper.xml gone? ?
In fact, after the maven compiler, there is a problem, it is believed, can only have a Java file Java files, ignoring the other gave, how to solve it? The introduction of scanning maven

And then introduced the maven pom configuration items to scan xml file in Java

<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
Published 14 original articles · won praise 4 · Views 251

Guess you like

Origin blog.csdn.net/Red_rose9/article/details/105077142