springboot
springboot学习整理
richer_2020
这个作者很懒,什么都没留下…
展开
-
@Component 和 @Bean 的区别
1.相同点 两者都是注入到spring容器中 2.不同点 @Component 作用在类上,将一个类注入到spring中 @Bean作用在方法上,将方法的返回值注入到spring中 @Bean通常配合@Configuration注解使用 3.为什么有了@Component 还需要 @Bean @Component 只能作用在自己写的类上 如果你导入第三方jar包,想将导入的类注入到spring中,只能通过@Bean注解,方法返回值为导入的类 ...原创 2020-05-20 10:08:25 · 218 阅读 · 0 评论 -
springboot整合mybatis-plus实现简答crud以及wrapper查询
1.导入pom依赖 <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.0.5</version> </dependency> 2.配置application.yml spring: server: port: 8.原创 2020-05-13 17:07:56 · 887 阅读 · 0 评论 -
整合springboot+shiro+mybatis+thymeleaf
1.导入依赖 主要添加shiro,springboot,thymeleaf,thymeleaf-shiro的依赖 <dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>2原创 2020-05-15 15:03:42 · 234 阅读 · 0 评论 -
整合springboot+springsecurity+thymeleaf
1.导入依赖 <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity4</artifactId> <version>3.0.4.RELEASE</version> </depend原创 2020-05-15 13:36:46 · 398 阅读 · 0 评论 -
springboot整合mybatis
1.引入mybatis-springboot,jdbc和mysql依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</versio原创 2020-05-15 11:10:06 · 141 阅读 · 0 评论 -
springboot定时任务
1.启动类上添加注解@EnableScheduling @SpringBootApplication @EnableScheduling public class MailScheduleApplication { 2.使用@Scheduled(cron = “58 0/20 * * * ?”)即可 @Scheduled(cron = "58 0/20 * * * ?") public void scheduledSend() { System.out.println("每5分钟发原创 2020-05-15 10:54:06 · 181 阅读 · 0 评论 -
springboot发送邮件
1.导入邮件的依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> 2.配置文件中编写mail的配置参数 spring: mail: username:原创 2020-05-15 10:51:25 · 166 阅读 · 0 评论 -
springboot中使用thymeleaf
1.首先要导入mvc和thymeleaf的依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency>原创 2020-05-15 10:40:07 · 1266 阅读 · 0 评论 -
springboot中使用springmvc
1.导入mvc的依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> 2.启用springmvc,使用注解@EnableWebMvc 如果你想diy一些定制化功能,只要写这个组原创 2020-05-15 10:11:50 · 1116 阅读 · 0 评论 -
springboot的重要注解@ConfigurationProperties
使用注解@ConfigurationProperties(prefix = “person”) 自动从yml中加载person的属性,注入类中 这是springboot特有的,这个很重要,源码里这个注解出现了很多次 application.yml配置文件 person: name: chendong age: 18 happy: true birth: 1888/08/18 maps: {k1: v1,k2: v2} lists: - code - music原创 2020-05-15 10:03:25 · 161 阅读 · 0 评论