Spring - Spring Common Annotations
Others
2019-11-25 00:43:10
views: null
- Outline
- Some simple order Spring comment
- This can be considered a type of water wave of consolidation
- Incomplete content
- Category some places may not be too logical
- And time is not very abundant
- The first written down to write your own, then finishing it Going
- Promise
- version
- Spring
- 5
- regret
- Related to the book, read half a month after finishing remembered
- Now it looks a little tired
- Some things may not be so accurate record of
- Identify problems and timely repair it
1. Basic
- @SpringBootApplication
- Outline
- Annotation entry class spring
- Synthesized by three old notes
- Types of
- Class Notes
- SpringBoot inlet class
- composition
- @SpringBootConfiguration
- Configuration class
- It is a special form of @Configuration
- I tell you that this is a configuration class
- @EnableAutoConfiguration
- Options
- Opened automatic configuration
- Automatic configuration, is characteristic of spring boot
- With a lot of convention instead of configuration
- @ComponentScan
- Options
- Open component scans
- Is automatically injected back, made a foundation
- Related Notes
- @Component
- @Controller
- @Service
- ref
- Annotation Type SpringBootApplication
- @Component
- Outline
- spring assemblies comment
- There are sub-categories
- @Controller
- @Service
- Types of
- Class Notes
- Component class
- Auto Scan
- Coordinate
- We need to work with @SpringBootApplication
- Mainly automatic scanning
- ref
- @Component
- @Controller
- Outline
- Spring WebMvc comments
- Types of
- Class Notes
- It appears on the Controller
- Coordinate
- We need to work with @SpringBootApplication
- Mainly automatic scanning
- ref
- Annotation Type Controller
- @Service
- Outline
- Spring Annotations
- Types of
- Class Notes
- It appears on the Service
- Service is usually implements an interface
- Coordinate
- We need to work with @SpringBootApplication
- Mainly automatic scanning
- ref
- Annotation Type Service
- @Autowired
- Outline
- Spring Annotations
- Automatic injection
- Types of
- Object Notation
- It appears on the object declaration
- Automatically recognize the type filled
- You can also manually perform
- Coordinate
- @Component
- @Controller
- @Service
- @Repository
- ref
- Annotation Type Autowired
- Spring annotation configuration (2) - @ Autowired
- Autowired to specify a particular type of fill objects
- @Configuration
- Outline
- Spring annotation class
- Types of
- Class Notes
- Class method will
- Generates runtime bean
- Qin autumn bean processing of these runtime
- For example WebConfig
- web configuration
- Bean itself
- ref
- Annotation Type Configuration
- @Repository
- Outline
- Spring annotation database interaction class
- Types of
- Class Notes
- Usually with a variety of template class, and persistent data exchange
- ref
- Annotation Type Repository
2. mvc
- @RequestMapping
- Outline
- Statement Controller responsible path
- Types of
- Class Notes
- It specifies the default path for the entire controller
- The following processing method, if the path is not described, this press path
- If described, the places of the root path, processing continues
- Method notes
- Usually also need to specify other
- Request method
- path
- Path parameters
- Coordinate
- Various @Mapping
- ref
- Annotation Type RequestMapping
- Various @Mapping
- Outline
- Corresponding to various protocols
- Types of
- Method notes
- Notes controller method of treating a particular protocol
- annotation
- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
- Coordinate
- @RequestMapping
- ref
- Annotation Type GetMapping
- Only gave GetMapping
- Others can jump from page
- @SessionAttributes
- Outline
- model attribute values declared to be saved in the session
- Types of
- Class Notes
- Use of a specific controller
- Using a controller on the line
- ref
- Annotation Type SessionAttributes
- @ModelAttribute
- Outline
- model property
- Function a little bit more
- Types of
- Notes property
- For use in the method parameter in reqeust
- From the model can fetch request in the corresponding type of object, and passes the parameter
- Method notes
- The return value of the method, as the model corresponding to the attribute value
- Also need to review this, a bit blurred
- ref
- Annotation Type ModelAttribute
3. rest
- @RestController
- Outline
- The controller labeled restcontroller
- Types of
- Class Notes
- The default class of controller method, with notes about
- @ResponseBody
- Return data, wrote in responsebody
- ref
- Annotation Type RestController
- @PathVariable
- Outline
- As attribute parameter
- Types of
- Notes property
- Url from the path taken field of the same name as the parameter
- ref
- Annotation Type PathVariable
- @ResponseStatus
- Outline
- Response to the specified property
- Types of
- Method notes
- Response to the specified property
- Coordinate
- @Mapping
- @RequestMapping
- Enum HttpStatus
- ref
- Annotation Type ResponseStatus
- Enum HttpStatus
- State, with responsestatus
- @RequestBody
- Outline
- Get content from RequestBody in
- Types of
- Notes property
- controller method parameters
- Obtained from the inside of the body request
- Question, seemingly in the request body, must be a complete object
- ref
- Annotation Type RequestBody
4. Test
- @RunWith(SpringRunner.class)
- Outline
- spring boot test notes
- JUnit is actually a comment
- JUnit 4
- Types of
- Class Notes
- Test category
- Need spring notes, we need to add
- Otherwise, spring relevant annotation will be ignored
- SpringRunner.class
- Designated runner
- This is not clear
- Generally use this right
- @SpringBootTest
- Outline
- spring boot test
- Complete spring context
- Class Notes
- Class Notes
- spring boot test class
- effect
- Start spring boot application context
- Use the default load context SpringBootContextLoader
- Use the default configuration is loaded @SpringBootConfiguration
- See other api documentation of it ...
- ref
- Annotation Type SpringBootTest
- @WebMvcTest
- Outline
- spring boot test notes
- spring web mvc related tests
- Types of
- Class Notes
- spring boot webmvc test class
- Testing only webmvc
- supplement
- If you need a complete spring context
- Please bring @SpringBootTest
- Coordinate
- We could do with this class and MockMvc
- ref
- [Annotation Type WebMvcTest](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.html
- @RequestParam
- slightly
ps
- ref
- spring in action 5th edition
- Other notes
- chilli
- testng
- spring security
- This should add ...
- spring valid
- Going this supplement
- spring configuration properties
- The need to supplement
Origin www.cnblogs.com/xy14/p/11925245.html