2022年6月20日 星期一

Spring Boot

 SOAP (XML) vs Restful (JSON)






Static Filtering vs Dynamic Filtering


H2 Console


Swagger


Versioning


===

Spring boot

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run"


=============

Dispatcher Servlet

====

RestController -> UserService (DAO) -> UserBean

=====

HATEOAS

在 REST 的 Level 3 模型中,客戶端可以從某個資源,知道還有哪些其他相關的資源



======

HttpMessageConverterAutoConfiguration

# Jackson to Object Mapping

# conversion from JSON to beans and beans to JSON

=====

# Spring boot initiator 

===
UserBean , UserDAOService (@Component)

===
#package

-> org.springframework.web.bind.annotation

=============
#Properties
=> application.properties

=========
# Class

=> ServletUriComponentBuilder ( UriComponentsBuilder with additional static factory methods to create links based on the current HttpServletRequest.)

=> MessageSource (Strategy interface for resolving messages, with support for the parameterization and internationalization of such messages.)

MappingJacksonValue

=========
#Dependency

<artifactId>spring-boot-starter-validation</artifactId>

<artifactId>spring-boot-starter-hateoas</artifactId>

<artifactId>jackson-dataformat-xml</artifactId>

<artifactId>springfox-swagger2</artifactId>

<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>

<artifactId>spring-boot-starter-actuator</artifactId>

<artifactId>spring-boot-starter-security</artifactId>

====
Advanced Restful 

# Internationalization
# Content Negotiation
# Auto Generation Swagger Documentation
# Swagger Documentation Format
=> https://springdoc.org/
=> swagger-ui.html

# Swagger Documentation with Custom Annotations
# Monitoring API with Spring boot Actuator
# Static Filtering 
# Dynamic Filtering
# Versioning RESTful Services - Basic Approach with URIs
#

======

# Annotation

@RestController

@GetMapping

@RequestHeader(name="Accept-Language", required=false)

@RequestParam(value = "name", defaultValue = "World") 

@RequestBody (Annotation indicating a method parameter should be bound to the body of the web request.)

@PostMapping

@RequestMapping(method=GET)

@Controller

@ResponseBody

@ ResponseStatus (Marks a method or exception class with the status ResponseStatus.code() and ResponseStatus.reason() that should be returned.)

@PathVariable (Annotation which indicates that a method parameter should be bound to a URI template variable)

==

@SpringBootApplication


====

@Component for @Autowired

@ComponentScan


=====

@ControllerAdvice

@ExceptionHandler (Annotation for handling exceptions in specific handler classes and/or handler methods.)


====

@Entity

@Id

@GeneratedValue

@Repository

public interface UserRepository extends JpaRepository<User, Integer>{

@ManyToOne(fetch=FetchType.LAZY)

@JsonIgnore

@OneToMany(mappedBy="user")

沒有留言:

張貼留言

IT Knowledge Map

https://docs.google.com/spreadsheets/d/1ZmN7G1unUAEpTPp5ObDnlAUtILLwwvluy-KHumMPEUU/edit#gid=0