1.新建就可启动
2.新建controller加入@RequestMapping就可跳转
3.需要加入视图解析配置才能跳转到页面 如freemarker(application.yml)
spring:
freemarker:
suffix: .html
4.静态文件的访问 如静态文件在statics下 两种方式
# 默认值为 /**
spring.mvc.static-path-pattern=/statics/**
# 默认值为 classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
spring.resources.static-locations=classpath:/statics/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
}
}
5.热部署网上说的加入devtool,不设置idea的edit configuration中的nothing为update class and还是不能用,不设置devtool 直接改configuration也可以热部署。devtool是重启,configuration是更新。
6.maven依赖跟spring不一样,如druid-spring-boot-starter,mybatis-plus-boot-starter
7.配置datasource和mybatis-plus
mybatis-plus:
mapper-locations: classpath:/mapper/*/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.ixiangliu.modules.*.entity
global-config:
#数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
# IGNORED:所有字段都更新和插入
# NOT_NULL:只更新和插入非NULL值
# NOT_EMPTY:只更新和插入非NULL值且非空字符串
field-strategy: NOT_NULL
#驼峰下划线转换
column-underline: true
8.dao层扫描不到,引入mybatis-plus-boot-starter,dao上@Mapper或者在启动类上加@MapperScan(basePackages = “com.example.demo.dao”)
9.Freemarker+shiro html中加入shiro tag需要设置FreemarkerConfig中的variables.put(“shiro”, shiroTag);