![](https://img-blog.csdnimg.cn/20200903133831690.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
spring boot
文章平均质量分 52
spring boot相关技术分享
无名·
君子性非异也,善假于物也。
心有猛虎,细嗅蔷薇。
展开
-
springboot 动态切换配置文件
根据文档描述,我们除application.properties外,还可以根据命名约定(命名格式:application-{profile}.properties)来配置,如果active赋予的参数没有与使用该命名约定格式文件相匹配的话,app则会默认从名为application-default.properties 的配置文件加载配置。如:spring.profiles.active=hello-world,sender,dev 有三个参数,其中 dev 正好匹配下面配置中的application-d原创 2021-12-28 17:24:12 · 677 阅读 · 0 评论 -
Java解析与生成yaml
1 yaml基本介绍yaml “Yet Another Markup Language” 仍是一种标记语言####1.1基本语法大小写敏感使用缩进表示层级关系缩进不允许使用tab,只允许空格缩进的空格数不重要,只要相同层级的元素左对齐即可‘#’ 表示注释2 Java解析与生成yaml2.1 在项目中添加Maven依赖<dependency> <groupId>org.yaml</groupId> <artifactId>原创 2021-07-23 08:11:55 · 3627 阅读 · 0 评论 -
tk.mybatis 调用oracle,生成ID
1.定义配置类 tk.mybatis.spring.mapper.MapperScannerConfigurer//配置類@Configurationpublic class IdConfig { @Bean public MapperScannerConfigurer mapperScannerConfigurer(){ MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();原创 2020-10-05 14:54:05 · 524 阅读 · 2 评论 -
springboot thymeleaf 引入js
由于springboot默认会扫描resources/static文件夹下面所以引入js路径: <script th:src="@{js/echarts.min.js}"></script>原创 2020-10-05 14:43:54 · 3243 阅读 · 0 评论 -
构建定时任务task
1.在线Cron表达式生成器网址https://cron.qqe2.com/2.定义scheduled@Componentpublic class HelloJob{ @Autowired private HelloService helloService; @Scheduled(cron = "0/5 * * * * ?") public void autoClose(){ helloService.closeJob();原创 2020-08-24 23:55:01 · 109 阅读 · 1 评论 -
springboot注入RestTemplate并使用
1.配置类实现@Configurationpublic class WebMvcConfig{ @Bean public RestTemplate restTemplate(RestTemplateBuilder builder){ return builder.build(); }}2.在容器中使用,注入到controller@RestControllerpublic class HelloController{ @Autowired private原创 2020-08-18 23:28:31 · 1221 阅读 · 0 评论 -
【简单整理】自定义resultmap常用情况整理
多表关联查询 CategoryVO是中包含SubCategoryVO的集合因为 CategoryVO中属性值包含集合,定义resultmap中使用到了collection1.实体类定义public class CategoryVO { private Integer id; private String name; // 三级分类 VO List private List<SubCategoryVO> subCatList; }2.对应xml原创 2020-08-17 23:04:50 · 1083 阅读 · 0 评论 -
【简单整理】PO、VO、BO区别
PO 持久对象VO 表现层对象 由web向模板渲染引擎层传输的对象BO 业务对象 由Service层输出的封装业务逻辑的对象原创 2020-08-15 23:36:57 · 503 阅读 · 0 评论 -
【简洁整理】springboot整合Swagger2文档
1.在pom.xml文件中(如果是分布式项目,加到父工程pom.xml中) <!-- swagger config 配置 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>原创 2020-08-09 22:56:51 · 89 阅读 · 0 评论 -
springboot扫描所有包以及组件包
1.找到springboot 启动类中 @ComponentScan注解@SpringBootApplication@MapperScan(basePackages = "com.wl.mapper")@ComponentScan(basePackages = {"com.wl","org.n3r.idworker"})@EnableSchedulingpublic class Application { public static void main(String[] args) {原创 2020-08-09 20:51:48 · 1855 阅读 · 0 评论 -
通过枚举类减少代码中直接使用字符串
在选项个数相对已知的情况下,为避免代码中写死一些值,方便可扩展,定义枚举类来实现。public enum Sex { woman(0, "女"), man(1, "男"), secret(2, "保密"); public final Integer type; public final String value; Sex(Integer type, String value) { this.type = type; th原创 2020-08-09 20:29:20 · 163 阅读 · 0 评论