idea+SpringBoot+Mybatis搭建Web项目

如题

1)新建一个项目:


2)选择【Spring Initializr,然后点击【Next】:


3)把项目信息写好,【Next】:


4)依次勾选所需设置,然后【Next】:




5)修改项目名和项目地址,【Finish】:


6)点击加载Maven(右下角):


7)等待Maven自动加载完成后,最初的项目结构如下图。在Springboot属性文件application.properties中,把数据库连接属性加上,同时可以设置服务端口:

spring.datasource.url = jdbc:mysql://localhost:3306/test
spring.datasource.username = root
spring.datasource.password =  root
spring.datasource.driverClassName = com.mysql.jdbc.Driver
#页面热加载
spring.thymeleaf.cache = false
#端口
server.port=8888

8)【resources目录下,【static】文件夹是放置各种静态资源,如css,js,img等文件的。【templates】文件夹则是默认放置网页的。当然也可以更改。PS.不晓得为啥没有,手动新建。

【static】下新建一个测试test.css,【templates】下新建一个hello.html:



9)写一个controller:

package com.qingqiuyue.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @RequestMapping("index")
    public String index() {
        return "hello";
    }
}

10)启动,完事~



PS.简单的小demo,但没跟数据库做交互

原文链接

idea+springboot+Mybatis搭建web项目:https://www.cnblogs.com/legoo/p/7646920.html



  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值