Wesley13 Wesley13
3年前
java 开发过程,各种各样的注解
@RetentionRetention(保留)注解说明,这种类型的注解会被保留到那个阶段. 有三个值:1.RetentionPolicy.SOURCE —— 这种类型的Annotations只在源代码级别保留,编译时就会被忽略2.RetentionPolicy.CLASS —— 这种类型的Annota
Easter79 Easter79
3年前
Spring注解校验1
Spring字段校验的注解说明限制说明@Null(https://my.oschina.net/u/561366)限制只能为null@NotNull(https://my.oschina.net/notnull)限制必须不为null@AssertFalse(https://my.oschina.net/u/24
Easter79 Easter79
3年前
SpringMVC中使用JSON
前台发送:传递JSON对象functionrequestJson(){$.ajax.({type:“post”,url:“${pageContext.request.contextPath}/testJson/responseJson”,
Stella981 Stella981
3年前
SpringAnnotation注解之@Autowired
@Autowired:自动装配,不用在bean里写<property属性来指定所依赖的属性1234@AutowiredpublicvoidsetUserDao(UserDaouserDao){this.userDaouserDao;}Autowired:表示spring
Stella981 Stella981
3年前
Spring boot method interceptor
概述需要对某些service方法添加日志和监控报警.找了好长时间,添加过程如下:1.编写@LogAndWarn注解2.编写拦截器LogAndWarnInterceptor3.编写切入点配置LogAndWarnAdviser4.在对应Service类或方法加上@LogAndWarn注解
Stella981 Stella981
3年前
Spring Boot @ControllerAdvice+@ExceptionHandler处理controller异常
需求:  1.springboot 项目restful 风格统一放回json  2.不在controller写trycatch代码块简洁controller层  3.对异常做统一处理,同时处理@Validated校验器注解的异常方法:  @ControllerAdvice注解定义全局异常处理类@ControllerAdvice
Stella981 Stella981
3年前
JUnit高级用法之@RunWith
@RunWith关于@RunWith注解,官方文档是这么描述的:Whenaclassisannotatedwith @RunWith orextendsaclassannotatedwith @RunWith,JUnitwillinvoketheclassitrefere
Stella981 Stella981
3年前
Spring 12 种 常用注解!
1.声明bean的注解@Component组件,没有明确的角色@Service在业务逻辑层使用(service层)@Repository在数据访问层使用(dao层)@Controller在展现层使用,控制器的声明(C)2.注入bean的注解@Autowired:由Spring提供@Inj
Easter79 Easter79
3年前
Spring的JavaConfig注解
传统spring一般都是基于xml配置的,不过后来新增了许多JavaConfig的注解。特别是springboot,基本都是清一色的javaconfig,不了解一下,还真是不适应。这里备注一下。@RestControllerspring4为了更方便的支持restfull应用的开发,新增了RestController的
Stella981 Stella981
3年前
EntityFrameworkCore 中实体的几种配置方法
EntityFramework有几种方式可实现数据库表与实体的关系配置(relationship)1.convention2.annotation3.fluentapi使用数据注解实体类通常是在Models目录下,直接在实体类上添加属性注解,比如Required/Key等.