[Studies] Spring Annotations

명원식·2023년 8월 17일
0

Studies

목록 보기
7/9
post-thumbnail

Spring Annotation

  • A method of configuring bean settings in Java code using annotations instead of XML.
  • As functionality becomes more complex, using annotations for configuration becomes more advantageous for maintenance compared to XML configuration.
  • Currently, a combination of XML configuration and annotation-based configuration is often used during application development.

26.1.1 Spring Annotation Provided Classes

Classes related to annotations for handling browser URL request processing:

26.1.2 <context:component-scan> Tag Functionality

By using the <context:component-scan> tag and specifying a package name, the application, when executed, will create beans from classes in the specified package that are annotated with annotations.

Usage Format:
<context:component-scan base-package="패키지이름" />

Various Stereotype Annotations


@Injecting Beans Using @Autowired

  • After configuring beans in XML and when the application runs, injecting beans to use them can make the XML file complex, leading to inconvenience in usage and management.

Characteristics of @Autowired

  • @Autowired automatically performs the dependency injection functionality that was traditionally done in XML, now achieved through annotations in code.
  • When using @Autowired, beans can be injected into properties without needing separate setters or constructors.
profile
but i brought potato salad

0개의 댓글