SpringBoot
noobmantest
这个作者很懒,什么都没留下…
展开
-
SpringBoot注解开发
步骤: 编写注解类 设置拦截器实现HandlerInterceptor接口,可重写preHandle、afterCompletion方法,在拦截前(后)处理事务。 在WebMvc配置类中添加拦截器 注解类: import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotati原创 2022-04-07 13:51:32 · 501 阅读 · 0 评论 -
springboot整合mybatis
yml配置: 配置数据源,配置mybatis的配置文件核心配置文件指定别名 config-location: # 指定mybatis的核心配置文件 mapper-locations: mapper/*.xml # mapper映射文件 type-aliases-package: com.studymybatis.entity # 指定别名 spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver usernam原创 2021-08-26 16:40:20 · 63 阅读 · 0 评论 -
SpringBoot测试
使用注解 @RunWith(SpringRunner.class) @SpringBootTest(classes = StudyTestApplication.class) 注意当测试类包名与启动类包名相同或者在其子包下。使用@SpringBootTest 不需要在括号内注明启动类 package test; import com.studytest.StudyTestApplication; import com.studytest.service.UserService; import org.原创 2021-08-26 16:37:23 · 441 阅读 · 0 评论 -
springboot环境配置,yml格式,不同环境切换
配置文件properties.yml格式 注意: 大小写敏感 数据前要有空格 数据格式:对象、数组、纯量、数据格式引用${} #识别顺序优先级 properties > yml > yaml server: port: 8088 # 对象 person: uName: 张三 age: 20 #对象单行格式 person2: { uName: 张三, age: 20 } # 数组格式 addr: - 北京 - 上海 #数组单行格式 addr2: [ 北京, 上海 ]原创 2021-08-25 12:39:24 · 1792 阅读 · 4 评论 -
Spring Boot入门案例,hello word
Spring Boot入门案例,hello word 注意spring2需要java8+,maven3.3+ pom配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http原创 2021-07-20 18:52:31 · 62 阅读 · 0 评论