2020
09-27
09-27
解决springboot的aop切面不起作用问题(失效的排查)
检查下springboot的启动类是否开启扫描@SpringBootApplication@ComponentScan(basePackages={"com.zhangpu.springboot"})另外springboot默认开启的EnableAspectJAutoProxy为true如果不放心可以增加:@EnableAspectJAutoProxy(proxyTargetClass=true)第二种可能:没有导入相关的jar<dependency><groupId>org.aspectj</groupId><artifactId>aspectjrt</artifactId></dependency><dependency><groupId>org.aspectj</groupId><a...
继续阅读 >
闲来无事,想学学springboot,开始搭建一个项目,但是一直显示mapper扫描不到的错误:“Exceptionencounteredduringcontextinitialization-cancellingrefreshattempt:org.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname‘userController':Unsatisfieddependencyexpressedthroughfield‘userMapper';nestedexceptionisorg.springframework.beans.factory.NoSuch...
后端的许多管理系统需要登陆者的信息,如shiro登陆后,会将登陆者的信息存储在shiro的session,在使用时需要多行代码获取用户信息。可以把获取在shiro中的登陆者信息封装在一个类中,使用时获取。本文主要讲述如何使用注解将值注入参数,shiro的配置请自行百度。定义注解新建一个InfoAnnotation.java的注解类,用于注解参数,代码如下:@Target(ElementType.PARAMETER)@Retention(RetentionPolicy.RUNTIME)public@interfaceInfoA...
Redis哨兵模式RedisSentinel介绍RedisSentinel是Redis高可用的实现方案。Sentinel是一个管理多个Redis实例的工具,它可以实现对Redis的监控、通知、自动故障转移。RedisSentinel主要功能Redis的Sentinel系统用于管理多个Redis服务器(instance),该系统执行以下三个任务:监控(Monitoring):Sentinel会不断地检查你的主服务器和从服务器是否运作正常。提醒(Notification):当被监控的某个Redis服务器出现问题...
一源(Origin)源指URL的协议,域名,端口三部分组成,如果这个三个成分都相同,就判定是同源,否则为不同源。同源策略(Sameoriginpolicy)是一种浏览器的约定,即在浏览器中禁止非同源访问。二CORSCORS即"跨域资源共享"(Cross-originresourcesharing),是一个W3C标准。它允许浏览器向跨源服务器,发出XMLHttpRequest请求,从而克服了ajax只能同源使用的限制。springboot也提供了cors的解决方法。下面将模拟浏览器跨域,并...
一restTemplate简介restTemplate底层是基于HttpURLConnection实现的restful风格的接口调用,类似于webservice,rpc远程调用,但其工作模式更加轻量级,方便于rest请求之间的调用,完成数据之间的交互,在springCloud之中也有一席之地。大致调用过程如下图二restTemplate常用方法列表forObeject跟forEntity有什么区别呢?主要的区别是forEntity的功能更加强大一些,其返回值是一个ResponseEntity,更加方便我们获得响应的body,head...
一前言springboot额外的特色是提供了后台应用监控,可以通过HTTP或者JMX的方式管理监控应用,本文主讲HTTP方式;其主要的功能是监控应用的健康状态,查看环境变量等;二pom.xmlspringboot2.1.1,主要引入actuator依赖,web依赖用于测试;<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springfra...
一什么是banner我们在启动项目的时候控制台会打印出spring的图案就是banner。二自定义banner1创建一个springboot项目。2在resource目录下创建一个名为banner.txt的文件。3往banner.txt中写入我们的图案。4引入web启动依赖。<dependencies><!--web启动器--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies>5编...
一说明spingMVC支持文件上传,我们通过Apach的commons-fileupload包的CommonsMultipartResolver去实现了spingMVC的MultipartResolver。本文章的示例是个简单的多文件上传,根据不同的业务自行修改。二pom.xlm<dependencies><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.3.3</version></dependency><dependency><groupId>or...