![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SpringBoot
文章平均质量分 86
风学长
这个作者很懒,什么都没留下…
展开
-
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
. ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spr...原创 2021-03-17 20:46:47 · 15828 阅读 · 9 评论 -
SpringBoot中使用Thymeleaf模板引擎无法实现return转化怎么办???
我们知道在SpringBoot中可以在@Controller类下的 @RequestMapping("")下的方法中根据return可以跳转到resources/templates下的html页面。但是你这里要注意一点必须是使用@Controller的Controller类,**绝对不可以使用@RestController,使用@RestController是无效的。 **1 pom文件<?xml version="1.0" encoding="UTF-8"?><project xm原创 2020-08-31 18:46:53 · 1312 阅读 · 0 评论 -
@Qualifier注解的使用
@Qualifier这个注解很简单。就是你一个接口有多个实现类。在Spring中使用了 @Autowired自动注入的时候不知道怎么选择是哪个具体的实现类了。例如UserDao有2个实现类。****如果你是Spring容器,给你一个UserDao接口,你知道在运行的时候使用那个实现类吗。所以使用@Qualifier来具体指向一下即可。这样对于接口的扩展十分有利。我们具体看看代码吧package com.zxf.test1;public class User { private Stri原创 2020-08-29 10:13:59 · 4315 阅读 · 3 评论 -
SpringBoot读取application.properits属性文件时有乱码怎么办
我们使用idea工具简单配置一下就可以了这样就把SpringBoot下的properties属性文件的格式统一了。原创 2020-08-18 17:41:23 · 1514 阅读 · 0 评论 -
Spring中使用@Autowired有Could not autowire.No beans of 编译异常提示。
有这样的编译提示粗不会影响我们的运行,但是对于代码强逼症的你,看着是否难受吧。那么我告诉大家怎么规范的使用Mapper接口很简单 我们只需在Mapper接口层加入@Repository注解即可这样一来就没有编译错误提示了。...原创 2020-08-13 14:07:42 · 2658 阅读 · 0 评论 -
使用SpringBoot注解方式处理事务回滚
我们在SpringBoot和MyBatis整合的时候,需要在SpringBoot中通过注解方式配置事务回滚1 Pojo类package com.zxf.domain;import java.util.Date;public class User { private Integer id; private String name; private String pwd; private String head_img; private String ph原创 2020-08-10 18:12:09 · 3505 阅读 · 3 评论 -
SpringBoot内嵌的任务异步管理器
我们有这样一个场景。大家看一下是并行执行好,还是串行执行好。在某平台注册用户 1需要接受邮件 2需要接受短信验证码。3 需要看一段短视频。我们这个实现需要选择并行执行。没有必要让用户一一做等待。我们下面通过线程休眠的形式来模拟,在线程休眠的时候其他线程也可以获得调度执行。1 在启动类中加入@EnableAsync //开启异步任务package com.zxf;import org.springframework.boot.SpringApplication;import org.spri原创 2020-08-04 11:38:11 · 2412 阅读 · 0 评论 -
class path resource [pay1.properties] cannot be opened because it does not exist
我们是在使用SpringBoot中的@PropertySource注解读取属性文件配置时候出现,无法找到配置文件的时候,我们要怎么怎么处理呢2020-07-29 12:27:35.051 ERROR 17980 --- [ restartedMain] o.s.boot.SpringApplication : Application run failedorg.springframework.beans.factory.BeanDefinitionStoreExcepti原创 2020-07-29 12:33:23 · 3698 阅读 · 1 评论 -
idea下开发SpringBoot如何实现热部署
热部署就是,在改变Java代码的时候,不用每次都手动重启应用服务。1 pom.xml文件加入依赖和配置<!--热部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> &原创 2020-07-28 19:49:31 · 2764 阅读 · 1 评论 -
SpringBoot通过Maven依赖形式的创建,并创建一个jar包
1 在New Project 中选择Maven,其他选择项不用选择,直接下一步既可。234 在pom.xml中加入相应的依赖坐标(1)项目类型为pom,表示为父项目,因为我们这里要创建一个前后端分离的项目。 <packaging>pom</packaging>(2) 父项目依赖 <parent> <groupId>org.springframework.boot</groupId> <a原创 2020-07-23 21:14:25 · 3677 阅读 · 0 评论 -
SpringBoot如何在yml配置文件中分区域块
我们看一下application.yml配置内容server: port: 8081spring: profiles: active: z2 ---server: port: 8082spring: profiles: z1---server: port: 8083spring: profiles: z2这样一来就不用创建多个properties属性配置文件了,大家可以根据自己的实际情况选择适用激活配置方式...原创 2020-06-17 12:20:50 · 8081 阅读 · 0 评论 -
SpringBoot如何在不同的环境中激活不同的properties属性文件
我们很多时候在开发,测试,试运行,上线需要读取不同的properties属性信息,我们如何在不同的生产环境中使用对应的properties文件呢我们有3个properties文件每个properties属性文件都有配置了端口号,我们可以在不同生产环境下激活不同的端口号在没有任何激活的前提下,默认使用的是application.properties文件的配置如果想要其他配置文件的配置信息,只需激活即可spring.profiles.active=z1 因为激活的是再次启动后原创 2020-06-17 10:59:33 · 8444 阅读 · 0 评论