创建项目:
下一步:
Web下勾选Spring Web、Spring Web Services
Template Englines勾选Thymeleaf
SQL勾选:MS SQL Server Driver、JDBC API 、 MyBatis Framework三项;点击next;
点击Finish
完成后的目录结构:
在templates文件下新建index.html页面,作为启动的初始页面
在在com.example.demo下新建controller文件夹建立文件夹controller
在controller文件夹下建一个简单的helloController类;(Controller类要添加@Controller注解,项目启动时,SpringBoot会自动扫描加载Controller)
package com.example.demo.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloController { @RequestMapping("/index") public String sayHello() { return "index"; } }
在resources文件夹下application中先配置DataSource基本信息
原文:https://www.cnblogs.com/wfy680/p/14940640.html