通过注解了解一个spring-boot项目

网友投稿 797 2022-05-30

看到一个spring-boot开源项目,感觉写得不错,打算花一些时间分析分析,首先从使用到的注解角度初步的看看;

## Swagger

https://github.com/swagger-api/swagger-core/wiki/annotations

@Api 标记一个类为Swagger资源

@ApiParam 为操作参数添加额外的meta数据

@ApiModelProperty 添加和操作model属性数据

@ApiOperation 描述一个操作,典型的是一个特定路径的http请求

@ApiResponse 描述操作可能的响应

@ApiIgnore

## spring/spring-boot

https://www.baeldung.com/spring-core-annotations  https://www.javatpoint.com/spring-boot-annotations

@Autowired  标记一个spring会去查找和注入的依赖

@Bean 标记一个组装spring bean的工厂方法

@Qualifier 和@Autowired一起提供一个bean的id或者name

https://www.baeldung.com/spring-annotations-resource-inject-autowire  https://stackoverflow.com/questions/4093504/resource-vs-autowired

@Resource 来自JSR标准 @Value 注入属性到beans中,可以在构造,设置和段注入

@Primary 当我们需要定义多个同一种类型的beans时,注入会因为不知道需要那个bean而失败,我们已经看到一个可选的方法:使用@Qualifier标记所有注入点,指定给bean特定的名称;然而,大多数时候我们只需要一个特定的bean而不是别的。我们可以用@Primary去简化这种场景。

@ImportResource 我们可以导入xml配置通过这个注解

@Component 这是个类级别的注解。它用来标记一个类为bean

https://www.baeldung.com/spring-postconstruct-predestroy

@PostConstruct spring只会调用@PostConstruct一次,在初始化bean的属性之后。可以是任意的访控属性,但不能是静态的。

@Transactional

@DateTimeFormat 用于在请求层级转换日期参数格式 - https://www.baeldung.com/spring-date-parameters

@Controller 这是个类级别的注解。它是一种特殊化的@Component。它标记一个类为网络请求处理器。通常和@RequestMapping一同使用

@ControllerAdvice

@Service 这是个类级别的注解。它告诉Spring这个类包含业务逻辑。

## spring Mvc and Rest Annotation

@RequestMapping 它用来映射网络请求。它有许多可选元素consumes, header, method, name, params, path, produces, and value

@GetMapping 它映射一个HTTP GET请求到一个特定的处理方法。它取代了@RequestMapping(method = RequestMethod.GET)

@PostMapping 它映射一个HTTP POST请求一个特定的处理方法。他取代了@RequestMapping(method = RequestMethod.POST)

@RequestBody 它用来绑定一个对象到方法形参给HTTP请求。内部使用HTTP消息转换器转换一个请求的消息体。

@ResponseBody  它绑定了一个返回值到相应体。它告诉spring boot框架去序列化一个返回对象到JSON和XML格式。

@RequestParam 它用来从URL中解析出query参数。

@RestController 它可以被认为是@Controller 和 @ResponseBody的组合。

## springboot anno

@Configuration

@SpringBootApplication 它是@EnableAutoConfiguration, @ComponentScan, 和 @Configuration的组合。

@ComponentScan

@ComponentScan.Filter

@EnableDiscoveryClient

@ConditionalOnMissingBean

@ConditionalOnProperty

## spring aop

@Aspect 作用是把当前类标识为一个切面供容器读取

@After final增强,不管是抛出异常或者正常退出都会执行

@Before 标识一个前置增强方法,相当于BeforeAdvice的功能,相似功能的还有

@Pointcut Pointcut是植入Advice的触发条件。

https://www.baeldung.com/java-default-annotations

@Retention

@Target

https://stackoverflow.com/questions/49624930/how-to-enable-requirespermissions-in-spring-mvc-project   https://blog.csdn.net/qi923701/article/details/75224554   https://zhuanlan.zhihu.com/p/37870725

@RequiresPermissions

## JPA

https://www.cnblogs.com/xuwenjin/p/8830850.html https://stackoverflow.com/questions/37729770/what-is-the-use-of-table-annotation-in-jpa   https://www.baeldung.com/jpa-entity-table-names

@Table

@Id

@Column

@GeneratedValue

@Transient

## poiji - excel 解析

@ExcelCell

@ExcelCellName

@ExcelRow

@ExcelTable

@ExcelWidths

https://github.com/ozlerhakan/poiji    https://www.wanaright.com/2020/04/10/annotation-poi-excel/  https://stackoverflow.com/questions/58981017/java-excel-pojo-mapping-in-poi

## spring kafka

@EnableKafka

@KafkaListener

https://www.baeldung.com/spring-kafka

## Jackson

@JsonFormat

@JsonIgnore

@JsonProperty

@JsonSerialize

@JacksonAnnotationsInside

@JsonIgnoreProperties

https://dzone.com/articles/jackson-annotations-for-json-part-4-general https://www.baeldung.com/jackson-jsonformat

## javax anno

@Max  被注释的元素必须是一个数字,其值必须大于等于指定的最小值

@Min 被注释的元素必须是一个数字,其值必须小于等于指定的最大值

@NotNull 注释的元素不能为null,可以为空字符串

@Nonnull

@Nullable

@Valid

@Pattern 被注释的元素必须符合指定的正则表达式。

@CheckForNull

https://blog.csdn.net/weixin_30439067/article/details/98076558 https://www.jianshu.com/p/32327ca2365f

## feign 一个java httpclient绑定

通过注解了解一个spring-boot项目

@EnableFeignClients

@Param

@RequestLine

@Headers

@HeaderMap

https://github.com/OpenFeign/feign  https://stackoverflow.com/questions/43868680/feign-client-does-not-resolve-query-parameter

## JUnit

@DisplayName

@Test

https://www.journaldev.com/21674/junit-display-name-displayname

## 其他技术栈分析

swagger整合spring mvc教程

https://blog.csdn.net/wangjun5159/article/details/47283125

spring后端国际化

https://www.logicbig.com/tutorials/spring-framework/spring-core/message-sources.html https://stackoverflow.com/questions/2952196/ant-path-style-patterns/22636142#22636142

在 Spring Boot 项目中使用 Swagger 文档

https://developer.ibm.com/zh/articles/j-using-swagger-in-a-spring-boot-project/ https://github.com/swagger-api/swagger-codegen

spring 过滤器、拦截器

jedisLock

https://redis.io/topics/distlock https://github.com/kaidul/jedis-lock/blob/master/src/main/java/com/github/jedis/lock/JedisLock.java

MyBatis Redis Extension

https://github.com/mybatis/redis-cache http://mybatis.org/mybatis-3/sqlmap-xml.html#cache https://redis.io/commands#hash https://spring.io/projects/spring-data-redis

MyBatis 通用 Mapper4 https://github.com/abel533/Mapper

Spring Boot API Project Seed、根据数据表名称生成对应的Model、Mapper、Service、Controller

https://blog.csdn.net/qq_36857572/article/details/81143014 https://www.jianshu.com/p/9962be89e2cf https://juejin.cn/post/6844903598422245383 https://github.com/lihengming/spring-boot-api-project-seed MyBatis Pagination - PageHelper https://github.com/pagehelper/Mybatis-PageHelper

mybatis 二级缓存

https://blog.csdn.net/xiaolyuh123/article/details/73912617 https://stackoverflow.com/questions/31760648/get-all-keys-from-spring-reloadableresourcebundlemessagesource/31761884#31761884

通过User-Agent判断浏览器环境版本

https://blog.csdn.net/fzy629442466/article/details/84784940 http://www.useragentstring.com/pages/useragentstring.php?name=Internet+Explorer https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox

elasticsearch 基于luence的非结构化索引库

https://www.elastic.co/guide/en/elasticsearch/reference/6.5/search-template.html

权重

https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html https://www.quora.com/What-is-inverted-index-It-is-a-well-known-fact-that-you-need-to-build-indexes-to-implement-efficient-searches-What-is-the-difference-between-index-and-inverted-index-and-how-does-one-build-inverted-index

IK分词

https://github.com/medcl/elasticsearch-analysis-ik

Prefix与keyword分词器

Ngram与edge-Ngram分词器

Excel生成

https://spreadsheet.dsl.builders/

Excel sheets 转换 Java classes

https://github.com/ozlerhakan/poiji

Feign一款基于注解与动态代理的HTTP Client。

https://github.com/OpenFeign/feign

Jackson Annotations for JSON (Part 4): General Annotations

https://dzone.com/articles/jackson-annotations-for-json-part-4-general https://github.com/thymeleaf/thymeleaf/issues/623 http://www.scienjus.com/get-field-annotation-property-by-jackson-contextualserializer/

Intro to Apache Kafka with Spring

https://www.baeldung.com/spring-kafka

Service(Mybatis/Eureka)

Eureka: 一款命名服务平台,输入是名称,返回是IP列表

https://spring.io/guides/gs/service-registration-and-discovery/ https://medium.com/swlh/spring-cloud-service-discovery-with-eureka-16f32068e5c7

Ribbon:客户端负载均衡

https://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html https://howtodoinjava.com/spring-cloud/spring-boot-ribbon-eureka/

Swagger/SwaggerGenerator

java项目代码风格

https://github.com/google/google-java-format intellij-java-google-style.xml

sonarqube代码检查

https://github.com/SonarSource/sonarqube

敏捷团队jira/rally

https://www.atlassian.com/zh/software/jira/comparison/jira-vs-rally

closure压缩,其实感觉现在很多前端框架已经采用webpack、gulp压缩打包,这个似乎没必要了、

https://github.com/google/closure-compiler/

Java 软件开发

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Excel表格打印区域如何排版更美观
下一篇:DBus数据库表结构变更处理方案
相关文章