随笔分类 -  spring

摘要:引入jar包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> 声明验证策略 // 执行插入时的 阅读全文
posted @ 2022-03-31 14:56 荣超 阅读(183) 评论(0) 推荐(0) 编辑
摘要:springboot 中使用 1.静态定时任务 添加注解 @EnableScheduling 在使用需要定时任务的方法上添加 @Scheduled(cron = "0 0/1 * * * ?") 这里使用了cron表达式 @Scheduled 的参数 1、cron cron表达式 2、zone 设置 阅读全文
posted @ 2022-03-31 14:45 荣超 阅读(288) 评论(0) 推荐(0) 编辑
摘要:添加依赖 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.5</version> </dependency> <dependency> <g 阅读全文
posted @ 2021-04-05 23:05 荣超 阅读(199) 评论(0) 推荐(0) 编辑
摘要:循环依赖的Bean必须要是单例 依赖的双方不能全部都使用构造器注入对方(依赖方至少有一个不能使用构造器注入) 如果使用@Bean注入的bean有依赖的话 (至少有一个依赖不能使用方法参数注入) 尽量避免使用循环依赖 阅读全文
posted @ 2020-12-29 11:10 荣超 阅读(178) 评论(0) 推荐(0) 编辑
摘要:@ControllerAdvice @RestControllerAdvice //纯接口系统可以使用我的系统只有api接口 使用了RestControllerAdvice @RestControllerAdvice public class BaseExceptionHandler { priva 阅读全文
posted @ 2020-10-21 17:03 荣超 阅读(481) 评论(0) 推荐(0) 编辑
摘要:自定义AuthcInterceptor拦截器类 @Component @Order(value = 1) public class AuthcInterceptor implements HandlerInterceptor { @Override public boolean preHandle( 阅读全文
posted @ 2020-10-21 16:54 荣超 阅读(586) 评论(0) 推荐(1) 编辑
摘要:@EnableCaching //启动spring缓存注解 @Configuration public class RedisConfig { @Bean public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory 阅读全文
posted @ 2020-04-28 16:09 荣超 阅读(684) 评论(0) 推荐(0) 编辑
摘要:public static <T> T jsonToBean(String json,Class<T> tClass){ try { //可以转换单引号 mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES,true); //键可以不用引号包 阅读全文
posted @ 2020-04-26 18:38 荣超 阅读(1580) 评论(0) 推荐(0) 编辑
摘要:使用工具类处理调用 直接调用就不会走代理了 @Component public class SpringContextUtil implements ApplicationContextAware { // Spring应用上下文环境 private static ApplicationContex 阅读全文
posted @ 2020-03-31 19:04 荣超 阅读(1311) 评论(0) 推荐(0) 编辑
摘要:引入 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <group 阅读全文
posted @ 2020-03-30 14:14 荣超 阅读(298) 评论(0) 推荐(0) 编辑
摘要:设置编码为utf-8 最好设置一下 我的刚开始没设置是正常的,换了台电脑就乱码了 Charset charset = StandardCharsets.UTF_8; @Bean public RestTemplate restTemplate(){ RestTemplate restTemplate 阅读全文
posted @ 2020-03-24 17:28 荣超 阅读(958) 评论(0) 推荐(0) 编辑
摘要:引入相关pom <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId> 阅读全文
posted @ 2019-06-28 19:11 荣超 阅读(657) 评论(0) 推荐(0) 编辑
摘要:首先引入需要的pom <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring-boot-web-starter</artifactId> <version>1.4.1</version> </dependen 阅读全文
posted @ 2019-06-15 15:24 荣超 阅读(1295) 评论(0) 推荐(0) 编辑
摘要:首先引入相关pom <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <group 阅读全文
posted @ 2019-06-13 18:43 荣超 阅读(1637) 评论(0) 推荐(0) 编辑
摘要:首先需要引入pom 这里使用nacos注册中心 所以引入了nacos-client 使用zookeeper注册中心的话需要引入其相应的client <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- 阅读全文
posted @ 2019-05-25 10:13 荣超 阅读(809) 评论(0) 推荐(0) 编辑
摘要:使用idea新建springboot项目beetl-spring-boot-starter 首先添加pom依赖 packaging要设置为jar不能设置为pom<packaging>jar</packaging> <dependency> <groupId>org.springframework.b 阅读全文
posted @ 2019-05-24 12:13 荣超 阅读(808) 评论(0) 推荐(0) 编辑
摘要:实际项目跑起来无影响,但是看起来不太爽。 可以在dao类添加org.springframework.stereotype.Repository 注解 或者可以在service类中使用 javax.annotation.Resource(替换org.springframework.beans.fact 阅读全文
posted @ 2019-05-06 14:59 荣超 阅读(4426) 评论(0) 推荐(0) 编辑
摘要:Spring MVC从3.0开始支持REST,而主要就是通过@PathVariable来处理请求参数和路径的映射。由于考虑到SEO的缘故,很多人喜欢把新闻的名称作为路径中的一部分去处理,这时候中文的名称就会遇到问题,没办法映射,这个是因为编码问题,只要到TOMCAT/conf下找到server.xm 阅读全文
posted @ 2015-06-12 09:17 荣超 阅读(573) 评论(0) 推荐(0) 编辑
摘要:在外键字段的get方法上加入@JsonIgnore 阅读全文
posted @ 2015-05-26 14:03 荣超 阅读(212) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示