Forgot password?

Basic Annotations

Basic Annotations:

  1. @Controller: We use @Controller to declare our class as our Controller class. It is specialization of @component and is autodetected through class path scanning.
  2. @RestController: @RestControlleris a sibling convenience annotation to create RESTful controllers. It adds the @Controller and @ResponseBody It converts the response to JSON or XML. 
  3. @RequestMapping: We use @RequestMapping to map HTTP requests to handler methods of MVC and REST.
  4. @requestParam: @RequestParamis a Spring annotation used to bind a web request parameter to a method parameter.
  5. @PathVariable: @PathVariableis a Spring annotation which indicates that a method parameter should be bound to a URI template variable.
  6. @Service: @Service is used to declare a class as a service class which is also a specialization of @component.
  7. @Repository: @Repository is used to declare a class as repository class which is used to store, retrieve, update an delete an object.
  8. @entity: @entity is used to specify a class as an entity class.
  9. @table: @table specifies the primary table for the annotated entity.
  10. @Autowired: @autowired annotation is used for automatic dependency injection.
  11. @Id: The @Idannotation marks a field as a primary key field. When a primary key field is defined the primary key value is automatically injected into that field by ObjectDB.
  12. @Column: Is used to specify the mapped column for a persistent property or field. If no Columnannotation is specified, the default values apply.
  13. @GeneratedValue: The @GeneratedValueannotation specifies that the primary key is automatically allocated by ObjectDB. 
  14. @nonNull: This annotation is used to set the default behavior to non-nullable in order to avoid annotating your whole codebase with @NonNull.
  15. @EnableAutoConfiguration: This annotation is used to automatically configure your application based on the dependencies you have added.
  16. @SpringBootApplication: This annotation is used in the class from where the execution of Spring Boot Application should start.
  17. @ComponentScan: This annotation is used to scan all the components included in Spring Boot project.

note: In Spring Boot, if we are using @SpringBootApplication then we don’t need to add other annotations like @EnableAutoConfiguration, @ComponentScan, @SpringBootConfiguration. Make sure in whichever class @SpringBootApplication is used it should have a main method. We will be discussing more about these annotations and their use further in our tutorial.

HTTP Requests:

  1. GET: The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data.
  2. POST: A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.
  3. DELETE: Removes all the current representations of the target resource given by URI.
  4. PUT: Replaces all the current representations of the target resource with the uploaded content.