Springboot + mybatis +xml配置

1.文档目录结构

Springboot + mybatis +xml配置_第1张图片

2.application.properties

Springboot + mybatis +xml配置_第2张图片

3.UserMapper.xml

Springboot + mybatis +xml配置_第3张图片

4.BootApplication.java

5.Controller

6.service接口

7.ServiceImpl.java 

8.Dao接口

9.entity
10.pom.xml
xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0modelVersion>

   <groupId>comgroupId>
   <artifactId>bootartifactId>
   <version>0.0.1-SNAPSHOTversion>
   <packaging>jarpackaging>

   <name>bootname>
   <description>Demo project for Spring Bootdescription>

   <parent>
      <groupId>org.springframework.bootgroupId>
      <artifactId>spring-boot-starter-parentartifactId>
      <version>2.0.3.RELEASEversion>
      <relativePath/> 
   parent>

   <properties>
      <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
      <java.version>1.8java.version>
   properties>

   <dependencies>
      <dependency>
         <groupId>org.springframework.bootgroupId>
         <artifactId>spring-boot-starter-webartifactId>
      dependency>
      <dependency>
         <groupId>org.mybatis.spring.bootgroupId>
         <artifactId>mybatis-spring-boot-starterartifactId>
         <version>1.3.1version>
      dependency>

      <dependency>
         <groupId>com.alibabagroupId>
         <artifactId>druidartifactId>
         <version>1.1.0version>
      dependency>

      <dependency>
         <groupId>mysqlgroupId>
         <artifactId>mysql-connector-javaartifactId>
         <scope>runtimescope>
      dependency>
      <dependency>
         <groupId>org.springframework.bootgroupId>
         <artifactId>spring-boot-starter-testartifactId>
         <scope>testscope>
      dependency>
   dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-maven-pluginartifactId>
         plugin>
      plugins>
      <resources>
         <resource>
            <directory>src/main/javadirectory>
            <includes>
               <include>**/*.propertiesinclude>
               <include>**/*.xmlinclude>
            includes>
            <filtering>falsefiltering>
         resource>
         <resource>
            <directory>src/main/resourcesdirectory>
            <includes>
               <include>**/*.propertiesinclude>
               <include>**/*.xmlinclude>
            includes>
            <filtering>falsefiltering>
         resource>
      resources>

   build>
project>
注意resources标签,必须填写,不然会搜索不到mapper.xml文件
UserDao不能写成Userdao 会出问题

你可能感兴趣的:(Springboot + mybatis +xml配置)