• Springboot+Mybatis+Thymeleaf


    工具Eclipse 2018

    Maven 配置

    ThymeLeaf 安装:  https://blog.csdn.net/xingqibaing/article/details/82787164

    spring项目创建:https://www.cnblogs.com/LUA123/p/8110285.html    

                               https://www.jb51.net/article/144068.htm  

                               https://blog.csdn.net/wangjiankai1993/article/details/80272886

    controller、Service层讲解 https://www.jianshu.com/p/06376b97b11e

    1、选择项目类型

               

    2、设置项目

          

    3、项目结构

    4、创建HelloController

    package com.example.demo;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    @RestController
    public class HelloController {
    @RequestMapping("/")
    public String hello() {
        return "Welcome to start SpringBoot!";
      }
    }

    5、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.0</modelVersion>
    <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.1.4.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>spring-boot2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-boot2</name>
    <description>Demo project for Spring Boot</description>

    <properties>
    <java.version>1.8</java.version>
    </properties>

    <dependencies>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
      </dependency>
    </dependencies>

    <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
    </build>

    </project>

    6、启动

             

    运行结果

     7、添加MyBatis、Thymeleaf依赖

    Thymeleaf 安装:  https://blog.csdn.net/xingqibaing/article/details/82787164

    Thymeleaf入门使用: https://blog.csdn.net/love_everybody/article/details/79870035

    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

     注意:运行报  Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

         由于依赖了mybatis-spring-boot-starter,此时还未配置数据源,在运行时需先配置数据源。

                              

     

  • 相关阅读:
    word批量打印工具,c#写的
    word添加页眉脚和设置各页不同的页眉页脚.
    打印机双面打印
    ORACLE OCP认证
    基于.net程序,使用cefsharp开发的打开网页工具,如何不加载图片
    在iis上运行的服务器端程序,运行一段时间后,访问都只出现一行乱码,回收进程池后又好了,求大神回复
    ArcGis API for JavaScript 开发笔记一 加载地图
    修改现有消息类让.net core项目支持Protobuf
    结合现有分布式系统的数据一致性思考
    让现有vue前端项目快速支持多语言
  • 原文地址:https://www.cnblogs.com/jeenmablog/p/10688909.html
Copyright © 2020-2023  润新知