springboot学习随笔
springboot的学习随笔
liubingle
这个作者很懒,什么都没留下…
展开
-
springboot启动错误笔记
PaymentMapper.xml: <resultMap id="BaseResultMap" type="com.lbl.springcloud.entities.Payment"> <id column="id" property="id" javaType="BIGINT" /> <id column="serial" property="serial" javaType="VARCHAR" /> </result原创 2020-10-27 12:36:10 · 347 阅读 · 0 评论 -
springboot简单邮箱任务
qq邮箱-设置-账户开启服务然后得到授权码,也是application.yml里的密码application.ymlspring: mail: username: 1937348985@qq.com password: xgpgfcasefdweqwd host: smtp.qq.com测试类编写:发送简单字段:@SpringBootTestclass Springboot10TaskApplicationTests { @Autowire原创 2020-09-13 10:07:43 · 193 阅读 · 0 评论 -
springboot简单定时任务
主函数加@EnableScheduling用于开启注解的定时任务@EnableScheduling//开启注解的定时任务@SpringBootApplicationpublic class Springboot10TaskApplication { public static void main(String[] args) { SpringApplication.run(Springboot10TaskApplication.class, args); }}原创 2020-09-13 09:59:36 · 88 阅读 · 0 评论 -
springboot异步任务
springboot异步任务使用@Async/告诉spring这是一个异步方法@Servicepublic class AsynService { @Async//告诉spring这是一个异步方法 public void hello(){ try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace()原创 2020-09-13 09:53:29 · 49 阅读 · 0 评论 -
springboot整合RabbitMQ
springboot整合RabbitMQ首先在docker上安装rabbitmq:docker pull rabbitmq:3-managementdocker imagesdocker run -d -p 5672:5672 -p 15672:15672 --name myrabbitmq rabbitmq镜像images第二次启动时:docker ps -a找到iddocker start rabbitmq容器id连接:http://172.20.10.10:15672/看连接是否成功原创 2020-09-11 19:39:55 · 44 阅读 · 0 评论 -
spring与redis整合和序列化问题
spring与redis整合首先用docker下载redis下载:docker pull redis运行:docker run -d -p 6379:6379 --name myredis docker.io/redis连接redis Desktop Manager然后开始在springboot上开始配置application.yml:spring: redis: host: 172.20.10.10自动配置好StringRedisTemplate和RedisTemplate原创 2020-09-11 11:52:34 · 88 阅读 · 0 评论 -
springboot缓存基础配置
springbbot缓存基础配置首先连接数据库一个实体类,employee.java(属性1加get,set方法等等)然后EmployeeMapper类@Mapperpublic interface EmployeeMapper{ @Select("select * from employee where id =#{id}") public Employee getEmployee(Integer id); @Update("update employee set las原创 2020-09-10 14:40:40 · 197 阅读 · 0 评论 -
springboot整合jpa
第一步:application.yml:spring: datasource: url: jdbc:mysql://localhost:3306/jpa?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8 username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernat原创 2020-09-09 11:57:31 · 85 阅读 · 0 评论 -
springboot使用mybatis修改数据库基本使用
EmployeeMapper.class:public interface EmployeeMapper{ public Employee getEmpById(Integer id) public void insertEmp(Employee employee);}Employee.class:Employee的属性和get,set方法(少了无法在网页上显示)EmployeeMapper接口:public interface EmployeeMapper{ publi原创 2020-09-09 10:37:21 · 276 阅读 · 0 评论 -
springboot使用Druid来连接数据库
springboot使用Druid来连接数据库(一):引入Druid依赖<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.23</version> </dependency>(二):applic原创 2020-09-08 13:07:52 · 479 阅读 · 0 评论 -
注册三大组件Servlet,Filter,Listener
注册三大组件Servlet,Filter,ListenerServlet:MyServerConfig.class@Bean //注册三大组件 public ServletRegistrationBean myServlet(){ ServletRegistrationBean registrationBean = new ServletRegistrationBean(new MyServlet(), "/MyServlet"); registrati原创 2020-09-06 15:27:34 · 95 阅读 · 0 评论 -
springboot中修改Servlet容器相关配置
法一:修改配置文件server.port=8083//Servlet设置server.servlet.xxx//Tomcat设置server.tomcat.uri-encoding=UTF-8server.tomcat.xxx法二:通过WebServerFactoryCustomizer类来重写它的方法@Configurationpublic class MyMvcConfig implements WebMvcConfigurer{ @Bean public Web原创 2020-09-06 14:25:32 · 68 阅读 · 0 评论 -
错误页面的自适应功能和数据传输实现
MyExceptionHandler.class下的1.浏览器和客户端返回的都是json(定制的数据都传过去了,无自适应效果) @ResponseBody @ExceptionHandler(UserNoExistException.class) public Map<String,Object> handException(Exception e){ Map<String,Object> map=new HashMap<>()原创 2020-09-06 13:18:45 · 83 阅读 · 0 评论 -
springboot2.x中exception和message无法在错误页面中显示
springboot2.x中exception和message无法在错误页面中显示,需要修改配置文件server.error.include-message=alwaysserver.error.include-exception=true原创 2020-09-06 10:17:10 · 363 阅读 · 1 评论 -
错误页面与模板引擎
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4"> <h1>status:[[${status}]]</h1> <h2>timestamp:[[${timestamp}]]</h2> </main>当error文件夹放在static下时,无模板引擎作用,此时页面显示为当放在template文件夹下时模板引擎起作用显示为原创 2020-09-06 10:01:41 · 137 阅读 · 0 评论 -
springboot2.x不能接收delete请求
配置文件中修改spring.mvc.hiddenmethod.filter.enabled=true原创 2020-08-28 17:31:11 · 286 阅读 · 0 评论 -
post和put的差别
<input type="hidden" name="_method" value="put" />put用于修改,post用于创建<input type="hidden" name="id" > id赋值原创 2020-08-28 16:08:41 · 299 阅读 · 0 评论 -
thymeleaf的改变网页显示日期的样式
<input th:value="${#dates.format(emp.birth,'yyyy-MM-dd HH:mm')}" >原创 2020-08-28 15:47:24 · 358 阅读 · 0 评论 -
修改员工属性时,将属性返回到修改页面上是option标签如何对应值
<select class="form-control" name="department.id"> <option th:selected="${dept.id==emp.department.id}" th:value="${dept.id}" th:each="dept:${depts}" th:text="${dept.getDepartmentName()}"></option> </sele原创 2020-08-28 15:32:36 · 127 阅读 · 0 评论 -
model.addAttribute()左边字符串与html页面的关系
controller包里的model.addAttribute(“emps”, employees)里的"emps",对应的是list.html里的emps,与@Mapping("emps")无关,"depts"同理,但是html里别忘了写{emps},与@Mapping("emps")无关,"depts"同理,但是html里别忘了写emps,与@Mapping("emps")无关,"depts"同理,但是html里别忘了写{}@GetMapping("/emps")//对应list.html里的<原创 2020-08-25 19:22:19 · 926 阅读 · 0 评论