自引链接:https://mp.csdn.net/postedit?not_checkout=1
一:新建Project,Idea是一款功能很强大的软件,有专门的生成springboot的插件
有时候会遇到timeout连接超时,将Defult默认的路径改为自定义:http://start.spring.io点击next
next
测试:
首先在applicationproperties文件配置
spring.datasource.url = jdbc:mysql://localhost:3306/test
spring.datasource.username = root
spring.datasource.password = 123456
spring.datasource.driverClassName = com.mysql.jdbc.Driver
#页面热加载
spring.thymeleaf.cache = false
#端口
server.port=8888
其次在静态文件夹static下创建test.css文件
在templates下创建HTML文件-hello.html
接下来写controller
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class indexController {
@RequestMapping("index")
public String index(){
return "hello";
}
}
启动程序,有两种方法
使用mybatis xml方式进行编写配置
1.jar包支持
<!--mybatis核心包-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
<!--MySQL的JDBC驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>
<!--junit单元测试包-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
2.xml配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis"/>
<property name="username" value="root"/>
<property name="password" value="123"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="mapper/Person.xml"/>
</mappers>
</configuration>
https://www.cnblogs.com/-xuzhankun/p/6627424.html(参考包含springboot+mybatis xml形式的搭建)