Spring - Spring Common Annotations

  1. Outline
    1. Some simple order Spring comment
    2. This can be considered a type of water wave of consolidation
      1. Incomplete content
      2. Category some places may not be too logical
      3. And time is not very abundant
      4. The first written down to write your own, then finishing it Going
  2. Promise
    1. version
      1. Spring
        1. 5
  3. regret
    1. Related to the book, read half a month after finishing remembered
      1. Now it looks a little tired
      2. Some things may not be so accurate record of
        1. Identify problems and timely repair it

1. Basic

  1. @SpringBootApplication
    1. Outline
      1. Annotation entry class spring
      2. Synthesized by three old notes
    2. Types of
      1. Class Notes
        1. SpringBoot inlet class
    3. composition
      1. @SpringBootConfiguration
        1. Configuration class
          1. It is a special form of @Configuration
          2. I tell you that this is a configuration class
      2. @EnableAutoConfiguration
        1. Options
          1. Opened automatic configuration
            1. Automatic configuration, is characteristic of spring boot
            2. With a lot of convention instead of configuration
      3. @ComponentScan
        1. Options
          1. Open component scans
            1. Is automatically injected back, made a foundation
        2. Related Notes
          1. @Component
          2. @Controller
          3. @Service
    4. ref
      1. Annotation Type SpringBootApplication
  2. @Component
    1. Outline
      1. spring assemblies comment
        1. There are sub-categories
          1. @Controller
          2. @Service
    2. Types of
      1. Class Notes
        1. Component class
        2. Auto Scan
    3. Coordinate
      1. We need to work with @SpringBootApplication
        1. Mainly automatic scanning
    4. ref
      1. @Component
  3. @Controller
    1. Outline
      1. Spring WebMvc comments
    2. Types of
      1. Class Notes
        1. It appears on the Controller
    3. Coordinate
      1. We need to work with @SpringBootApplication
        1. Mainly automatic scanning
    4. ref
      1. Annotation Type Controller
  4. @Service
    1. Outline
      1. Spring Annotations
    2. Types of
      1. Class Notes
        1. It appears on the Service
          1. Service is usually implements an interface
    3. Coordinate
      1. We need to work with @SpringBootApplication
        1. Mainly automatic scanning
    4. ref
      1. Annotation Type Service
  5. @Autowired
    1. Outline
      1. Spring Annotations
      2. Automatic injection
    2. Types of
      1. Object Notation
        1. It appears on the object declaration
        2. Automatically recognize the type filled
          1. You can also manually perform
    3. Coordinate
      1. @Component
      2. @Controller
      3. @Service
      4. @Repository
    4. ref
      1. Annotation Type Autowired
      2. Spring annotation configuration (2) - @ Autowired
        1. Autowired to specify a particular type of fill objects
  6. @Configuration
    1. Outline
      1. Spring annotation class
    2. Types of
      1. Class Notes
        1. Class method will
          1. Generates runtime bean
          2. Qin autumn bean processing of these runtime
        2. For example WebConfig
          1. web configuration
          2. Bean itself
    3. ref
      1. Annotation Type Configuration
  7. @Repository
    1. Outline
      1. Spring annotation database interaction class
    2. Types of
      1. Class Notes
        1. Usually with a variety of template class, and persistent data exchange
    3. ref
      1. Annotation Type Repository

2. mvc

  1. @RequestMapping
    1. Outline
      1. Statement Controller responsible path
    2. Types of
      1. Class Notes
        1. It specifies the default path for the entire controller
          1. The following processing method, if the path is not described, this press path
          2. If described, the places of the root path, processing continues
      2. Method notes
        1. Usually also need to specify other
          1. Request method
          2. path
          3. Path parameters
    3. Coordinate
      1. Various @Mapping
    4. ref
      1. Annotation Type RequestMapping
  2. Various @Mapping
    1. Outline
      1. Corresponding to various protocols
    2. Types of
      1. Method notes
        1. Notes controller method of treating a particular protocol
    3. annotation
      1. @GetMapping
      2. @PostMapping
      3. @PutMapping
      4. @DeleteMapping
      5. @PatchMapping
    4. Coordinate
      1. @RequestMapping
    5. ref
      1. Annotation Type GetMapping
        1. Only gave GetMapping
        2. Others can jump from page
  3. @SessionAttributes
    1. Outline
      1. model attribute values ​​declared to be saved in the session
    2. Types of
      1. Class Notes
        1. Use of a specific controller
          1. Using a controller on the line
    3. ref
      1. Annotation Type SessionAttributes
  4. @ModelAttribute
    1. Outline
      1. model property
        1. Function a little bit more
    2. Types of
      1. Notes property
        1. For use in the method parameter in reqeust
          1. From the model can fetch request in the corresponding type of object, and passes the parameter
      2. Method notes
        1. The return value of the method, as the model corresponding to the attribute value
          1. Also need to review this, a bit blurred
    3. ref
      1. Annotation Type ModelAttribute

3. rest

  1. @RestController
    1. Outline
      1. The controller labeled restcontroller
    2. Types of
      1. Class Notes
        1. The default class of controller method, with notes about
          1. @ResponseBody
            1. Return data, wrote in responsebody
    3. ref
      1. Annotation Type RestController
  2. @PathVariable
    1. Outline
      1. As attribute parameter
    2. Types of
      1. Notes property
        1. Url from the path taken field of the same name as the parameter
    3. ref
      1. Annotation Type PathVariable
  3. @ResponseStatus
    1. Outline
      1. Response to the specified property
    2. Types of
      1. Method notes
        1. Response to the specified property
    3. Coordinate
      1. @Mapping
      2. @RequestMapping
      3. Enum HttpStatus
    4. ref
      1. Annotation Type ResponseStatus
      2. Enum HttpStatus
        1. State, with responsestatus
  4. @RequestBody
    1. Outline
      1. Get content from RequestBody in
    2. Types of
      1. Notes property
        1. controller method parameters
          1. Obtained from the inside of the body request
          2. Question, seemingly in the request body, must be a complete object
    3. ref
      1. Annotation Type RequestBody

4. Test

  1. @RunWith(SpringRunner.class)
    1. Outline
      1. spring boot test notes
      2. JUnit is actually a comment
        1. JUnit 4
    2. Types of
      1. Class Notes
        1. Test category
          1. Need spring notes, we need to add
          2. Otherwise, spring relevant annotation will be ignored
    3. SpringRunner.class
      1. Designated runner
        1. This is not clear
        2. Generally use this right
  2. @SpringBootTest
    1. Outline
      1. spring boot test
      2. Complete spring context
    2. Class Notes
      1. Class Notes
        1. spring boot test class
    3. effect
      1. Start spring boot application context
      2. Use the default load context SpringBootContextLoader
      3. Use the default configuration is loaded @SpringBootConfiguration
      4. See other api documentation of it ...
    4. ref
      1. Annotation Type SpringBootTest
  3. @WebMvcTest
    1. Outline
      1. spring boot test notes
      2. spring web mvc related tests
    2. Types of
      1. Class Notes
      2. spring boot webmvc test class
        1. Testing only webmvc
    3. supplement
      1. If you need a complete spring context
        1. Please bring @SpringBootTest
    4. Coordinate
      1. We could do with this class and MockMvc
    5. ref
      1. [Annotation Type WebMvcTest](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.html
  4. @RequestParam
    1. slightly

ps

  1. ref
    1. spring in action 5th edition
  2. Other notes
    1. chilli
    2. testng
    3. spring security
      1. This should add ...
    4. spring valid
      1. Going this supplement
    5. spring configuration properties
      1. The need to supplement

Guess you like

Origin www.cnblogs.com/xy14/p/11925245.html