file-->project
删除掉mvnw和mvnw.cmd
application.properties
#连接数据库
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
#前端页面的前缀
spring.mvc.view.prefix=/pages/
#前端页面的后缀
spring.mvc.view.suffix=.html
#设置端口号
server.port=8081
创建indexController
package com.zhike.springdemo3.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* author:liuguoxin
* created time : 2019/4/15 11:00
*/
@Controller
public class IndexController {
@RequestMapping("/index")
@ResponseBody
public String index(){
return "index";
}
}
访问http://localhost:8081/index