springboot mysql mybatis---2

application.properties


#db_lms 数据库名
spring.datasource.url=jdbc:mysql://localhost:3306/db_ssmdemo?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT
#Mysql 用户名
spring.datasource.username=root
#MySQL 密码
spring.datasource.password=###@@@
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#
#mysql 版本8以后
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver


mybatis.mapper-locations=classpath:mappers/*.xml

# 配置静态资源地址,默认地址:"classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/
#spring.web.resources.static-locations=classpath:/templates/
## 如果将html页面直接放在templates目录下,可能省略下面这行配置
#spring.mvc.view.prefix=views
## 必须的,不然报错
#spring.mvc.view.suffix=.html
server.port=80

#spring.thymeleaf.cache=false

#热部署模块
devtools:
restart:
#热部署开关
enabled: true
#指定热部署的目录
additional-paths: src/main/java
#指定目录不更新
exclude: test/**
mvc:   #静态文件
static-path-pattern : /static/**
#模板引擎
thymeleaf:
model: HTML5
prefix: classpath:/templates/
suffix: .html
#指定编码
encoding: utf-8
#禁用缓存 默认false
cache: false

WebConfig.java
package com.example.demo6.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author xxx
 * @Date 2023/6/12 22:04
 * @dec
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
//    @Override
//    public void addViewControllers(ViewControllerRegistry registry) {
        spring.mvc.view.prefix + /index + spring.mvc.view.suffix 构成完整的请求地址
        访问项目根目录即是访问 /views/index.html页面
//        registry.addViewController("/").setViewName("/index2");
//    }


//    /** 添加拦截器 **/
//    @Override
//    public void addInterceptors(InterceptorRegistry registry){
//        registry.addInterceptor(new MyInterceptor());
//    }

    /** 静态资源处理 **/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置虚拟路径为项目得static下面
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}

猜你喜欢

转载自blog.csdn.net/ck3345143/article/details/131258812